「语音模式」包含在 Pro 里,开通会员后显示预览。
用法
import { ChatVoice } from './ChatVoice.jsx'
// Without status the block plays its sample conversation. Drive it from your speech pipeline:
<ChatVoice
locale="en"
status={call.status} // 'idle' | 'listening' | 'thinking' | 'speaking' | 'ended'
transcript={call.lines} // [{ id, role: 'user' | 'assistant', text, shown? }]; shown = characters said so far
level={call.micLevel} // 0..1, how loud the current voice is
onStart={() => call.start()}
onMute={(muted) => call.mute(muted)}
onEnd={() => call.hangUp()}
onSend={(text) => call.say(text)}
error={call.micBlocked}
onRetry={() => call.askForMicrophone()}
/>属性
| 属性 | 类型 | 默认值 | 作用 |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | 内置文字和示例对话所用的语言。 |
status / transcript / level | string / Array<{ id, role, text, shown? }> / number | — | 用你自己的语音流程驱动:圆球显示的轮次、字幕(shown 表示已说出的字符数,后面带光标)和音量 0 到 1。不传 status 时播放示例。 |
script | Array<{ role: 'user' | 'assistant', text }> | sample trip | 未接入时自动播放的对话。 |
autoStart | boolean | true | 一出现就开始听;设为 false 时等点一下圆球再开始。 |
onStart / onMute / onEnd | () => void / (muted) => void / ({ seconds }) => void | — | 点圆球开始、麦克风静音或取消静音、结束对话时调用。 |
onSend | (text) => Promise<string> | void | — | 用打字代替说话发了一条消息。resolve 回复文字时,示例模式会把它“说”出来。 |
error / onRetry | boolean / () => Promise | void | false | 麦克风被禁用:显示如何开启、“重试”(onRetry)和“改用打字”。 |
labels | object | — | 替换任意内置文字(键名见 copy.js)。 |
className | string | — | 加在根元素上的类名。 |
装进你的项目
Pro 包含这个区块的完整源码。复制指令,让你的 Agent 把它安装到项目中。
ChatVoice.jsxchat-voice.csscopy.jskit.jsxkit.cssui/base-button/tokens.cssREADME.md
区块本身、样式和文案、共用的 kit、用到的组件和 tokens.css 会一起装进同一个文件夹。
