Convert incoming text to speech as it arrives. The server buffers text, detects sentence boundaries and streams hex-encoded audio chunks in JSON messages.
README.md for installation and runtime requirements.wss://openapi.myvocal.ai/v2/ai/speech/websocketstringSkyblight-Turbodedicated_concurrencyconnected_success.task_start.task_started.task_continue messages.task_flush to process buffered text immediately.task_finish.task_finished.1000.is_final=true: last chunk of the current audio request.sentence_end: all audio for the current sentence has arrived.task_finished: the entire session has ended.task_start after connecting:{
"event": "task_start",
"model": "Skyblight-Turbo",
"voice": "YOUR_VOICE_ID",
"language": "en",
"format": "mp3",
"sample_rate": 32000,
"bitrate": 128000,
"channel": 1,
"priority": "dedicated_concurrency",
"voice_setting": {
"speed": 1.0,
"vol": 1.0,
"pitch": 0,
"emotion": "calm"
},
"subtitle_enable": true,
"subtitle_type": "word_streaming",
"session_id": "client-session-001"
}stringtask_starttask_started before sending text.stringSkyblight-Turbo onlystringvoice is required even when using timbre_weights.stringzh, en, jastringmp3mp3, pcm, wav, flac, pcmu_raw, pcmu_wavpcmu_raw and pcmu_wav use 8 kHz G.711 μ-law.integer320008000, 16000, 22050, 24000, 32000, 44100integer12800032000, 64000, 128000, 256000format=mp3.integer11 or 21 is mono and 2 is stereo.stringdedicated_concurrency onlystringnumber1.00.5 to 2.0number1.00 and at most 10integer0-12 to 12stringhappy, sad, angry, fearfuldisgusted, surprised, calmbooleanfalsebooleanfalse$$...$$ and escape backslashes correctly.string[]original/pronunciationMyVocal/My Vocal{
"voice": "PRIMARY_VOICE_ID",
"timbre_weights": [
{
"voice_id": "VOICE_ID_A",
"weight": 50
},
{
"voice_id": "VOICE_ID_B",
"weight": 50
}
]
}object[]voice must still be a valid voice ID.stringinteger1 to 100voice_modify with format=mp3.integer-100 to 100integer-100 to 100integer-100 to 100stringspacious_echo, auditorium_echolofi_telephone, roboticbooleanfalsestringsentencesentence, word, word_streamingtask_started, send the following message as often as needed:{
"event": "task_continue",
"text": "Hello, welcome to MyVocal."
}stringtask_continuestringtask_flush.{
"event": "task_cancel"
}task_canceled. The connection stays open.{
"event": "task_flush"
}task_flushed. The session stays open. Flushing an empty buffer is allowed.{
"event": "task_finish"
}task_finished and closes normally with code 1000.task_start next.task_continue.data.audio in arrival order.task_continue.1000.error_code, error and base_resp, stop the task and handle the indicated error.stringword: word or character.word_begin: start offset in the text.word_end: end offset in the text.time_begin: start time in the audio.time_end: end time in the audio.0 indicates success.{
"event": "task_continued",
"data": {
"audio": "fff3..."
},
"is_final": false,
"session_id": "client-session-001",
"extra_info": {
"audio_sample_rate": 32000,
"audio_format": "mp3",
"usage_characters": 28
},
"base_resp": {
"status_code": 0,
"status_msg": "success"
}
}{
"event": "task_failed",
"error_code": "400100",
"error": "请求参数无效",
"base_resp": {
"status_code": 2013,
"status_msg": "invalid params"
}
}continuous_sound.format=opus.voice_modify with format=mp3.2204.task_started, do not send task_start again.| Location | Parameter | Type | Required | Description |
|---|---|---|---|---|
| Header | API-Key | string | Yes | MyVocal API key, sent in the WebSocket handshake header. |