Voices
How a voice is chosen today
Section titled “How a voice is chosen today”Every avatar has one voice, set on the avatar in 2wai Studio. Every session of that avatar speaks in it.
voice_idonPOST /v1/sessionsis accepted and ignored, so an integration that already sends it keeps working, but it has no effect. Leave it out of new code.- To change how an avatar sounds, change its voice in Studio. The next session uses the new voice.
- There is no way to push your own audio:
POST /v1/sessions/{id}/audioanswers409 not_available_on_livekit(see Bring your own TTS).
Planned: cloning a voice
Section titled “Planned: cloning a voice”The shape below is what the API is planned to accept. Today it returns 501 voice_cloning_unavailable.
Option A: upload a file, then reference it
Section titled “Option A: upload a file, then reference it”-
Upload the clip with
POST /v1/files:Terminal window curl -X POST https://api.2wai.ai/v1/files \-H "Authorization: Bearer $TWAI_SECRET_KEY" \-F "file=@reference-clip.wav"The response carries a
file_id. -
Create the voice from that
file_id:Terminal window curl -X POST https://api.2wai.ai/v1/voices \-H "Authorization: Bearer $TWAI_SECRET_KEY" \-H "Content-Type: application/json" \-d '{"name": "narrator","file_id": "<file_id from step 1>"}'
Option B: clone directly from a URL
Section titled “Option B: clone directly from a URL”curl -X POST https://api.2wai.ai/v1/voices \ -H "Authorization: Bearer $TWAI_SECRET_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "narrator", "url": "https://example.com/reference-clip.wav" }'Provide exactly one of file_id or url, not both.
Use clean, single-speaker audio: no background music or noise, no clipping, and no long silences at the start or end.
Listing your voices
Section titled “Listing your voices”curl https://api.2wai.ai/v1/voices \ -H "Authorization: Bearer $TWAI_SECRET_KEY"const res = await fetch('https://api.2wai.ai/v1/voices', { headers: { Authorization: `Bearer ${process.env.TWAI_SECRET_KEY}` },});const voices = await res.json();A voice listed here does not change what a LiveKit session sounds like; only the voice set on the avatar in Studio does.
- Sessions for session creation.
- Creating avatars for setting an avatar’s voice in Studio.