Skip to main content

Cartesia

Cartesia implementation for @micdrop/server.

This package provides high-quality real-time text-to-speech implementation using Cartesia's streaming API.

Installation

npm install @micdrop/cartesia

Cartesia TTS (Text-to-Speech)

Usage

import { CartesiaTTS } from '@micdrop/cartesia'
import { MicdropServer } from '@micdrop/server'

const tts = new CartesiaTTS({
apiKey: process.env.CARTESIA_API_KEY || '',
modelId: 'sonic-english', // Cartesia model ID
voiceId: 'a0e99841-438c-4a64-b679-ae501e7d6091', // Voice ID
language: 'en', // Optional: specify language
speed: 'normal', // Optional: speech speed
})

// Use with MicdropServer
new MicdropServer(socket, {
tts,
// ... other options
})

Options

OptionTypeDefaultDescription
apiKeystringRequiredYour Cartesia API key
modelIdstringRequiredCartesia model ID to use
voiceIdstringRequiredVoice ID for speech synthesis
languageCartesiaLanguageOptionalLanguage code for speech
speed'fast' | 'normal' | 'slow'OptionalSpeech speed

Supported Languages

The package supports the following languages:

CodeLanguageCodeLanguageCodeLanguage
enEnglishfrFrenchdeGerman
esSpanishptPortuguesezhChinese
jaJapanesehiHindiitItalian
koKoreannlDutchplPolish
ruRussiansvSwedishtrTurkish

Getting Started

  1. Sign up for a Cartesia account and get your API key
  2. Choose a model ID and voice ID from the Cartesia dashboard
  3. Install the package and configure with your credentials
import { CartesiaTTS } from '@micdrop/cartesia'

const tts = new CartesiaTTS({
apiKey: 'your-cartesia-api-key',
modelId: 'sonic-english', // Or sonic-multilingual for multiple languages
voiceId: 'your-preferred-voice-id',
language: 'en',
speed: 'normal',
})

// Use with MicdropServer
new MicdropServer(socket, {
tts,
// ... other options
})