bricks/docs/ai/vadtext.md
2025-11-18 16:01:43 +08:00

18 lines
983 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

```markdown
# VadText
控件功能:一个集成语音采集、音频播放和语音识别文本展示的复合控件,用户点击按钮开始录音,当检测到语音结束时自动将音频转为 WAV 格式并发送至后端进行语音识别,返回结果实时显示在文本区域中。
类型:容器控件
父类控件bricks.VBox
## 初始化参数
- `opts.name` *(可选)*: 控件名称,默认为 `'asr_text'`
- `opts.height`: 默认设置为 `'100%'`,占据父容器全部高度。
- 其他继承自 `VBox` 的通用布局参数(如 `width`, `align` 等)也可传入。
## 主要事件
- `audio_ready`: 当语音活动检测VAD捕获到一段完整的语音并生成音频数据时触发。携带参数为 `Float32Array` 类型的音频样本数据。
- `changed`: 当语音识别完成且有非空文本内容时,在停止录音后触发。携带当前控件的值对象 `{ [name]: text }`,可用于表单提交或状态同步。
```