Manage independent contexts on one connection. A context can use one or more voices. Use it for dialogue with several speakers or for incremental single-voice input with V4 or V3 Turbo.
myvocal_v3 (default), myvocal_v4 and myvocal_v3_turbo.api-key, an available voice and priority=dedicated_concurrency.Connect → register voices and send inputs → receive audio → close_context → wait for is_final → close_socketapi-key: YOUR_API_KEY):wss://api.voicelibrary.co/enterprise/v1/text-to-dialogue/websocket/multi?model_id=myvocal_v4&priority=dedicated_concurrency&format=mp3_128{"context_id":"demo","voices":["YOUR_VOICE_ID"],"inputs":[{"text":"你好,欢迎使用语音合成。","voice_id":"YOUR_VOICE_ID","new_turn":true}]}{"context_id":"demo","close_context":true}context_id and wait for is_final=true. When all tasks are complete, send {"close_socket":true} and wait for a normal close. You can also use close_socket to finish all contexts together.inputs. Its close_context processes remaining text without a separate flush. Standard multi-context TTS uses different messages and a different completion sequence.wss://api.voicelibrary.co/enterprise/v1/text-to-dialogue/websocket/multistringmyvocal_v3 (default), myvocal_v4, myvocal_v3_turbodedicated_concurrency?priority=dedicated_concurrency
&model_id=myvocal_v3
&format=mp3_128
&language_code=en
×tamps=true
&text_normalization=auto
&seed=618021
&enable_logging=truestringdedicated_concurrency onlystringmyvocal_v3myvocal_v3, myvocal_v4, myvocal_v3_turbostringmp3_128mp3_64、mp3_96、mp3_128、mp3_192pcm_8000、pcm_16000、pcm_22050、pcm_24000、pcm_44100ulaw_8000stringzh, English en, Cantonese yue or Filipino fil.myvocal_v4 and myvocal_v3_turbo support the same 94 output languages, including Mandarin zh, Cantonese yue, English en, Japanese ja and Korean ko. See Output languages for the complete list.booleanfalsetrue to receive character timings with audio messages.stringonauto, on, offauto: let the system choose whether to normalize.on: always normalize.off: disable normalization.integer1 to 4294967295booleantruefalse, the request does not retain history and related history features are unavailable.context_id, send its first message to register voices and optional settings.inputs.context_id.flush to process currently buffered text immediately.close_context to finish one context.close_socket to finish every context and close the connection.1000.context_id must contain voices:{
"context_id": "scene-001",
"voices": [
"YOUR_VOICE_ID_A",
"YOUR_VOICE_ID_B"
],
"voice_settings": {
"stability": 0.5
},
"inputs": [
{
"text": "Hello, how may I help you today?",
"voice_id": "YOUR_VOICE_ID_A",
"new_turn": true
}
]
}stringcontext_id in every message except a message containing only close_socket.string[]inputs[].voice_id must refer to a registered voice.objectstability setting described below. The HTTP fields similarity_boost, style and speed do not belong in this context configuration.number0 to 1inputs as often as needed:{
"context_id": "scene-001",
"inputs": [
{
"text": "Sure, I can check that for you.",
"voice_id": "YOUR_VOICE_ID_A"
}
]
}object[]stringstringvoices.booleanfalsetrue to end the current delivery segment and start a new speaking turn.voice_id also starts a new turn.{
"context_id": "scene-001",
"flush": true
}flush forces the service to process the current context’s buffered text and keeps the context open.inputs afterward.{
"context_id": "scene-001",
"keep_alive": true
}keep_alive resets the context’s 20-second idle timer without generating audio.{
"context_id": "scene-001",
"close_context": true
}close_context processes the remaining text, sends is_final for that context,flush before close_context is unnecessary.{
"close_socket": true
}close_socket processes and closes all contexts. When every active context has finished, the server1000.{
"audio": "<BASE64_AUDIO>",
"context_id": "scene-001"
}audio: Base64-encoded audio chunk.context_id: context that owns the audio.context_id.{
"context_id": "scene-001",
"is_final_audio_for_turn": true
}{
"context_id": "scene-001",
"is_final": true
}timestamps=true, an audio message may also include:{
"audio": "<BASE64_AUDIO>",
"context_id": "scene-001",
"alignment": {
"chars": ["H", "e", "l", "l", "o"],
"char_start_times_ms": [0, 80, 150, 220, 300],
"char_durations_ms": [80, 70, 70, 80, 90]
},
"normalized_alignment": {
"chars": ["H", "e", "l", "l", "o"],
"char_start_times_ms": [0, 80, 150, 220, 300],
"char_durations_ms": [80, 70, 70, 80, 90]
}
}alignment: character timings for the original text.normalized_alignment: character timings for normalized text.chars: sequence of characters.char_start_times_ms: start time for each character, in milliseconds.char_durations_ms: duration of each character, in milliseconds.is_final and closes.voice_settings only in the first message for a context.1008.1000.{
"code": "INVALID_PARAMETER",
"field": "voice_settings.stability",
"message": "voice_settings.stability must be between 0 and 1"
}{
"error": "INVALID_PRIORITY",
"message": "This WebSocket requires priority=dedicated_concurrency"
}INVALID_PARAMETER: invalid parameter, message structure or field value.INVALID_PRIORITY: the request did not use dedicated_concurrency.DEDICATED_CONCURRENCY_REQUIRED: the account has no available dedicated concurrency.MAX_CONTEXT_LIMIT_EXCEEDED: more than five active contexts on one connection.INSUFFICIENT_QUOTA: insufficient account quota.STREAMING_SERVICE_ERROR: speech generation is temporarily unavailable.field, stop sending further messages on the connection,| Location | Parameter | Type | Required | Description |
|---|---|---|---|---|
| Header | api-key | string | Yes | MyVocal enterprise API key, sent in the WebSocket handshake header. |
| Query | model_id | string | No | Dialogue model for the connection. V4 and V3 Turbo use this dialogue WebSocket protocol. Allowed values: myvocal_v3, myvocal_v4, myvocal_v3_turbo. If you omit this parameter, the default model is myvocal_v3. |
| Query | language_code | string | No | Optional two- or three-letter language code, for example zh (Mandarin), yue (Cantonese) or fil (Filipino). If omitted, infer the language from the text. V4 and V3 Turbo support the same 94 languages. |