Voice Cloning and Realtime TTS
Use the Soniox SDK to create a cloned voice from a short reference clip, wait until the clone is ready for the TTS model, then pass that cloned voice ID to either REST Text-to-Speech or realtime Text-to-Speech.
SonioxClient.DefaultTtsModel targets Soniox TTS v2 (tts-rt-v2) for both REST and realtime generation. Existing applications can continue to select SonioxClient.TtsRealtimeV1ModelId explicitly.
Paid API calls
Voice creation and live TTS calls can spend Soniox credits. Keep live examples behind explicit environment flags and use short text prompts when testing with a low balance.
Setup
Install the SDK and set your API key:
1 2 | |
For local integration tests, this repo also loads a root .env file:
1 2 | |
Use a clear speech sample that you have the rights and consent to clone. The SDK example uses a short reference clip and deletes the created clone in a finally block after the TTS call finishes.
Create a Cloned Voice
1 2 3 4 5 6 7 8 9 10 11 | |
The returned voice.Id is the value to pass as the voice field in TTS requests. Before using it, poll client.Voices.GetVoiceAsync(voice.Id) until the entry for SonioxClient.DefaultTtsModel has Status == VoiceModelStatus.Ready.
REST TTS with a Clone
1 2 3 4 5 6 | |
Use client.Voices.DeleteVoiceAsync(voice.Id) when the clone is only needed for a one-off test.
Realtime TTS with a Clone
The realtime client is generated from src/libs/Soniox/tts.asyncapi.yaml and lives under Soniox.Realtime.Tts.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
Read realtimeClient.ReceiveUpdatesAsync(...) until you receive audio chunks and the matching terminated event for the stream. Send TtsKeepAlive messages during idle periods, and cancel by sending TtsCancel with the same stream_id.
Paid Test Flags
Live examples and smoke tests stay opt-in:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
SONIOX_RUN_PAID_TESTS=1 can be used as a shared opt-in for paid Soniox tests. Without these flags, the realtime example only verifies generated message serialization and the live tests are marked inconclusive.