@ottervoice/core
createVoiceSession(config) 与 createOtterVoiceSession(config) 使用完全相同的
统一 audio-turn 配置;后者只是语义更明确的别名。
VoiceSessionConfig 要点
Section titled “VoiceSessionConfig 要点”| 字段 | 说明 |
|---|---|
mode |
half_duplex · full_duplex · push_to_talk · streaming_transcript |
runtime |
平台适配器 |
providers.audioLlm |
必需;原生语音模型或服务端复合语音栈 |
providers.asr |
可选字幕 ASR;当 audio-turn Provider 不返回输入转写时使用 |
language |
偏好 ASR 语言,如 zh-CN |
asrPartial |
是否发 asr_partial,默认 true |
turnDetection |
听用户说话时的 VAD |
interruptionDetection |
助手播放时的更严 VAD(barge-in) |
policy |
自动听、允许打断、误打断恢复等 |
audioLlmSystemPrompt / audioLlmMaxTokens |
仅可信 Node/服务端 Session;浏览器标准模式由网关注入 |
audioLlmStartTiming |
after_audio 并行降首响;默认 after_asr_final |
Core 只与单个 audio-turn Provider 对话。该 Provider 可以是
原生语音模型,也可以是网关后组合的 ASR → LLM → TTS。若它声明
transcribesInput: true,Core 会把 Provider 返回的输入转写作为 asr_final;
否则应额外提供 caption ASR。
底层 LLMProvider 与 TTSProvider 仍供可信后端实现复合
AudioLLMProvider,不再是 VoiceSessionConfig.providers 的槽位。浏览器/App
应使用 server-managed Provider,并让自有网关覆盖所有业务与成本策略。
TurnDetectionConfig
Section titled “TurnDetectionConfig”| 字段 | 默认(解析后) | 含义 |
|---|---|---|
strategy |
hybrid |
volume · manual · hybrid |
minSpeechMs |
500 |
判定开始说话的最短有声时长 |
silenceTimeoutMs |
1200 |
静音多久结束轮次(低延迟可试 350–600) |
maxTurnMs |
120000 |
单轮上限 |
volumeThreshold |
0.02 |
RMS 阈值 |
VoiceSessionPolicy
Section titled “VoiceSessionPolicy”| 字段 | 含义 |
|---|---|
autoStartListening |
start 后是否自动进入 listening |
allowInterruption |
是否允许 barge-in |
interruptionTailIgnoreMs |
试探性暂停后忽略扬声器尾音(默认 200) |
falseInterruptionSilenceMs / TimeoutMs |
误打断恢复窗口 |
interruptionCooldownMs |
恢复播放后冷却 |
postPlaybackVadRearmMs |
播放结束后等待安静基线(默认 300) |
会话生命周期
Section titled “会话生命周期”await session.start();await session.finish();await session.dispose();监听事件:事件指南。错误码与用量同在 VoiceSessionEventMap。