Text to Speech
Generate speech from text.
Voice clones — your own cloned voices. Pass a voice clone ID as voiceId.
Library voices — ready-made voices from the shared library. Pass a library voice ID as referenceId.
Character limits
| Free | Pro, Premium |
|---|---|
| 200 characters per generation | 500 characters per generation |
sonus.tts.generate({ text, voiceId | referenceId, ... })
Generate speech from text. Returns a sound object with a direct download link.
| Name | Type | Required | Description |
|---|---|---|---|
text | string | yes | Text to convert to speech |
voiceId | string | no | ID of a voice clone you own |
referenceId | string | no | ID of a voice from the shared library |
name | string | no | Name for the generated sound |
With a voice clone
const { sound, error } = await sonus.tts.generate({
text: 'Hello in my cloned voice!',
voiceId: 'your_clone_id',
})
With a library voice
const { sound, error } = await sonus.tts.generate({
text: 'Welcome to SonusLab!',
referenceId: 'library_voice_id',
})
sound is { id, name, audioKey, audioUrl }.
sonus.tts.listVoices({ search, language, pageSize })
Browse voices in the shared library.
| Name | Type | Required | Description |
|---|---|---|---|
search | string | no | Filter library voices by title |
language | string | no | Filter by language code |
pageSize | number | no | Results per page, 1–50 (default: 20) |
const { voices, error } = await sonus.tts.listVoices({ search: 'narration' })
Voice is { id, name, description, previewUrl, languages, tags }.
