Text to Speech
Generate speech from text. The SDK abstracts provider differences behind a single interface.
ElevenLabs
High-quality multilingual voices with fine-grained control over stability and similarity.
Models
eleven_multilingual_v2eleven_flash_v2_5eleven_turbo_v2_5
Fish Audio
Best for custom voice clones. Pass a voice clone ID as the voiceId.
Character limits
FreePro, Premium200 characters per generation500 characters per generation
sonus.tts.generate({ text, voiceId, provider, ... })Generate speech from text. Returns a sound object with a direct download link.
| Parameter | Type | Description |
|---|---|---|
textrequired | string | Text to convert to speech |
voiceIdrequired | string | Voice ID to use |
providerrequired | "elevenlabs" | "fish" | TTS provider |
name | string | Name for the generated sound |
modelId | string | ElevenLabs model (default: eleven_multilingual_v2) |
stability | number | Voice stability 0–1 (ElevenLabs only) |
similarityBoost | number | Similarity boost 0–1 (ElevenLabs only) |
ElevenLabs
const { sound, error } = await sonus.tts.generate({
text: 'Welcome to SonusLab!',
voiceId: 'voice_id_here',
provider: 'elevenlabs',
stability: 0.5,
similarityBoost: 0.75,
})Fish Audio (with voice clone)
const { sound, error } = await sonus.tts.generate({
text: 'Hello in my cloned voice!',
voiceId: 'your_clone_id',
provider: 'fish',
})sonus.tts.listVoices()List available built-in voices.
const { voices, error } = await sonus.tts.listVoices()