MyVocal新增公用音色列表与调用说明
详情请访问:https://my.feishu.cn/wiki/YMrZw7FWIiuSgskQS8tcihnKnph?from=from_copylink
Realtime ASR 使用 WebSocket 建立长连接。客户端持续发送音频切片(PCM bytes → Base64),服务端实时返回增量识别(partial)与最终识别(committed)结果;可选返回词级时间戳。
wss://openapi.myvocal.ai/asr/realtime| 参数名 | 类型 | 必填 | 默认值参数 | 说明 |
|---|---|---|---|---|
api-key | string | 是 | - | API Key(放在 URL query) |
model_id | string | 否 | echo_v1_realtime | 模型 ID |
audio_format | string | 否 | pcm_16000 | 音频格式(见 2.3) |
commit_mode | string | 否 | vad | 提交模式:vad / manual(见第 4 节) |
word_timestamps | boolean | 否 | false | 是否返回词级时间戳 |
language | string | 否 | 省略=auto | 语言代码; Language="" 时不会写入 URL(表示 auto) |
languagelanguage 参数language=xx(例如 en / zh / ja)audio_format 支持(PCM 16-bit 单声道)pcm_8000pcm_16000pcm_22050pcm_24000pcm_44100wss://openapi.myvocal.ai/asr/realtime?api-key=YOUR_KEY&model_id=echo_v1_realtime&audio_format=pcm_16000&commit_mode=vad&word_timestamps=false
wss://openapi.myvocal.ai/asr/realtime?api-key=YOUR_KEY&model_id=echo_v1_realtime&audio_format=pcm_16000&commit_mode=vad&word_timestamps=false&language=jpn
wss://openapi.myvocal.ai/asr/realtime?api-key=YOUR_KEY&model_id=echo_v1_realtime&audio_format=pcm_16000&commit_mode=manual&word_timestamps=true
| 字段名 | 类型 | 必填 | 说明 |
|---|---|---|---|
message_type | string | 是 | 固定为 input_audio_chunk |
audio_base_64 | string | 是 | 音频 PCM bytes 的 Base64 |
sample_rate | integer | 是 | 与 audio_format 对应(如 pcm_16000 → 16000) |
commit | boolean | 是 | 是否提交(manual 模式句末 true;vad 模式通常 false 发送即可) |
示例:普通音频帧
{
"message_type": "input_audio_chunk",
"audio_base_64": "BASE64_PCM_BYTES...",
"sample_rate": 16000,
"commit": false
}
当配置 WireProtocolSimple 时,上行只发送:
audio_base_64sample_rate注意:该模式 不包含
message_type和commit字段,适用于“服务端不要求 message_type/commit”的兼容场景。
示例:WireProtocolSimple 音频帧
{
"audio_base_64": "BASE64_PCM_BYTES...",
"sample_rate": 16000
}
commit_mode=vad(默认)commit=false 的音频帧)commit_mode=manualcommit=falsecommit=true示例:句末提交(manual)
{
"message_type": "input_audio_chunk",
"audio_base_64": "BASE64_PCM_BYTES_LAST...",
"sample_rate": 16000,
"commit": true
}
服务端返回 JSON,根据 message_type 分发回调。
session_started{
"message_type": "session_started",
"session_id": "xxxx"
}
partial_transcript{
"message_type": "partial_transcript",
"text": "hello wor..."
}
committed_transcript{
"message_type": "committed_transcript",
"text": "hello world"
}
committed_transcript_with_timestamps当 URL 参数 word_timestamps=true 时,最终结果可能返回 words:
{
"message_type": "committed_transcript_with_timestamps",
"text": "hello world",
"words": [
{ "word": "hello", "start": 0.12, "end": 0.42 },
{ "word": "world", "start": 0.50, "end": 0.86 }
]
}
统一按 ErrorMessage 结构处理以下 message_type:
errorauth_errorquota_exceeded_errorunaccepted_terms示例:鉴权失败
{
"message_type": "auth_error",
"error": "Invalid API key"
}
示例:额度不足
{
"message_type": "quota_exceeded_error",
"error": "Quota exceeded"
}
HandshakeTimeout:默认 10 秒(Config 不设置或 <=0 时)WSURL:必填(不填会报错)manual 模式务必在句末发送 commit=true 才会产生最终结果;language(省略即 auto)