[实时转写]:完成录音期间转写显示,包含partial事件、本地streaming STT和终端实时反馈
This commit is contained in:
@@ -111,6 +111,16 @@ The first implementation is a per-turn heuristic endpoint, not persistent voicep
|
||||
4. 主说话人画像就绪后,`OWNER_SPEAKER_ABSENT_MS` 是结束正式问题采集的主条件;主说话人连续缺席达到该值后直接进入 STT,不再额外等待普通 VAD 最小时长。
|
||||
5. 普通 VAD 静音仍作为画像不足或音色特征不可用时的兜底,最大录音时长仍作为最终保护。
|
||||
|
||||
## Realtime Transcript Revision
|
||||
|
||||
录音期间新增 partial transcript 通道,用于解决“说话时看不到文字结果”的体验问题:
|
||||
|
||||
1. Pipeline 事件新增 `transcript_partial`。终端 reporter 将其显示为 `实时转写:<文本>`,最终结果仍显示为 `转写结果:<文本>`。
|
||||
2. partial transcript 只用于用户反馈,不写入 `ConversationContext`,不触发 LLM;LLM 仍只消费 final STT 结果。
|
||||
3. 当 final ASR/TTS 走 cloud 时,partial transcript 使用本地 `sherpa-onnx` streaming STT,避免对云端 ASR 高频请求。
|
||||
4. `VoiceAssistantPipeline` 在 `speech_started` 后把 capture 阶段已开始录音的帧 feed 给 realtime STT session;当 partial 文本变化时才 emit,避免刷屏。
|
||||
5. `OWNER_REALTIME_TRANSCRIPT_ENABLED=1` 默认启用;设置为 `0` 可临时回退到只显示 final transcript。
|
||||
|
||||
## Model Files
|
||||
|
||||
```text
|
||||
@@ -141,6 +151,7 @@ models/
|
||||
8. Pipeline stage failure: emit `stage_error`, recover to standby, and keep the process alive unless startup dependencies are missing.
|
||||
9. Playback drain misconfiguration: negative `OWNER_POST_PLAYBACK_DRAIN_MS` remains invalid; non-zero values are treated as explicit user tuning rather than default behavior.
|
||||
10. Speaker profile threshold misconfiguration: non-positive `OWNER_SPEAKER_PROFILE_MIN_MS` fails config validation.
|
||||
11. Realtime STT failure: startup model缺失按 `model-check` 暴露;capture 中 partial session 失败不得把 partial 文本写入上下文。
|
||||
|
||||
## Testing Strategy
|
||||
|
||||
@@ -155,6 +166,8 @@ models/
|
||||
9. First utterance preservation test validates that frames immediately after ACK are not discarded by post-playback drain.
|
||||
10. Low-latency endpoint test validates that a short first question ends by primary speaker absence without waiting for a repeated second question.
|
||||
11. Transport batching test validates that queued SoundDevice frames are returned together.
|
||||
12. Partial transcript event test validates that realtime text appears after speech start and before final transcript.
|
||||
13. Context isolation test validates partial transcript does not enter LLM messages.
|
||||
|
||||
## Migration
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
9. 首句保留问题:真人验收显示唤醒应答后仍会感觉“第一句话没有获取到”,当前 ACK 后会执行 `flush_input -> read/drop -> flush_input`,默认额外丢弃 50 ms 麦克风输入,用户若紧跟提示开口会损失正式问题开头。
|
||||
10. 实时消费问题:`SoundDeviceAudioTransport.read_frames()` 每次只返回一个队列帧,在音频回调批量积压时会增加 pipeline 对真实麦克风流的追帧成本。
|
||||
11. 画像门槛问题:`PrimarySpeakerVadRecorder._profile_ready()` 把主说话人画像就绪阈值绑定到 `OWNER_VAD_MIN_DURATION_MS`,默认至少等待 250 ms 后主说话人端点才参与结束判断,短句用户会被迫等普通 VAD 静音或重复说话。
|
||||
12. 实时转写问题:当前终端只在整段录音结束并完成 final STT 后显示“转写结果”,用户说话期间看不到任何文字反馈,无法判断系统是否已经听到并识别当前句子。
|
||||
|
||||
## 详细需求
|
||||
|
||||
@@ -74,6 +75,9 @@
|
||||
16. SoundDevice 音频输入 SHALL 支持一次读取当前队列中可用的多个帧,避免 pipeline 在真实麦克风输入积压时逐帧追赶。
|
||||
17. 主说话人画像就绪 SHALL 使用独立配置 `OWNER_SPEAKER_PROFILE_MIN_MS`,默认 `120` ms;该阈值不得被 `OWNER_VAD_MIN_DURATION_MS` 放大。
|
||||
18. 主说话人端点在画像就绪后 SHALL 以 `OWNER_SPEAKER_ABSENT_MS` 作为主要结束条件;主说话人连续缺席达到配置值后 SHALL 结束采集,不得额外等待普通 VAD 的最小时长门槛。
|
||||
19. 录音期间 SHALL 支持 partial transcript 事件;当本地 streaming STT 产生新的中间文本时,终端 SHALL 立即显示 `实时转写:<文本>`。
|
||||
20. partial transcript SHALL 只作为用户可见反馈,不得直接写入对话上下文;LLM 输入仍以最终 `transcript_final` 文本为准。
|
||||
21. 当 `OWNER_SPEECH_PROVIDER=cloud` 时,partial transcript SHALL 使用本地 streaming STT,避免对云端 ASR 进行高频请求。
|
||||
|
||||
### 非功能需求
|
||||
|
||||
@@ -115,6 +119,7 @@
|
||||
12. `OWNER_CONTEXT_MODE=session_memory`:本次进程内临时上下文。
|
||||
13. `OWNER_POST_PLAYBACK_DRAIN_MS=0`:ACK 或 TTS 播放完成后只 flush 已积压输入,不额外读取并丢弃新音频。
|
||||
14. `OWNER_SPEAKER_PROFILE_MIN_MS=120`:主说话人画像参与端点判断的最低有效语音长度。
|
||||
15. `OWNER_REALTIME_TRANSCRIPT_ENABLED=1`:启用录音期间本地 streaming STT 中间结果显示。
|
||||
|
||||
终端输出:
|
||||
|
||||
@@ -222,6 +227,7 @@ standby
|
||||
6. ACK 后首句保留:播放“我在”期间允许输入队列积压,播放完成后只执行一次队列 flush 清掉播放回声,不再额外读取 `post_playback_drain_ms` 毫秒并丢弃,默认值改为 0。
|
||||
7. 批量读帧:真实 SoundDevice 输入在拿到首帧后立即 drain 当前队列中所有可用帧并返回给 pipeline,使 wake、capture 和 VAD 能在同一个循环内处理积压帧。
|
||||
8. 快速主说话人结束:画像就绪最低语音长度由 `OWNER_SPEAKER_PROFILE_MIN_MS` 控制,默认 120 ms;一旦画像就绪,主说话人缺席计时达到 `OWNER_SPEAKER_ABSENT_MS` 即结束,不再叠加 `OWNER_VAD_MIN_DURATION_MS`。
|
||||
9. 实时转写显示:CaptureStage 在 `speech_started` 后把已录入的帧同时送入本地 streaming STT session;每当 partial 文本变化时发出 `transcript_partial`,终端显示 `实时转写:<文本>`;最终段落仍交给 configured STT provider 生成 `transcript_final`。
|
||||
|
||||
### 数据库/状态管理变更
|
||||
|
||||
@@ -253,6 +259,8 @@ standby
|
||||
| ACK 后额外丢弃音频截断首句 | 高 | 高 | 默认 `OWNER_POST_PLAYBACK_DRAIN_MS=0`;播放结束后只 flush 已积压输入;新增首句保留回归测试 |
|
||||
| 主说话人画像等待过久 | 高 | 中 | 新增 `OWNER_SPEAKER_PROFILE_MIN_MS=120`;画像就绪后主说话人缺席结束不再等待普通 VAD 最小时长 |
|
||||
| 麦克风帧队列积压导致状态滞后 | 中 | 中 | `SoundDeviceAudioTransport.read_frames()` 批量返回已积压帧;新增批量读帧测试 |
|
||||
| partial STT 误识别影响 LLM | 中 | 中 | partial 只显示给用户,不进入 `ConversationContext`;最终 LLM 输入仍以 final STT 为准 |
|
||||
| 本地 streaming STT 增加 CPU 占用 | 中 | 中 | 只在 capture started 且用户语音已开始后 feed;重复 partial 文本不重复输出;提供 `OWNER_REALTIME_TRANSCRIPT_ENABLED=0` 回退 |
|
||||
| 手写音色特征不等于严格声纹识别 | 中 | 中 | 明确第一版为本轮临时主说话人端点;不承诺长期主人识别;保留后续接入 speaker embedding 模型的接口空间 |
|
||||
| Pipeline 重构影响现有 CLI/测试 | 中 | 高 | 保留 `run-live` 命令和兼容类名;新增事件顺序测试、两轮回归测试和错误恢复测试 |
|
||||
| 本地 KWS 增加启动加载时间 | 低 | 中 | 模型约 15 MB,启动加载一次;不在每轮重复加载 |
|
||||
@@ -331,6 +339,7 @@ standby
|
||||
7. `Live assistant pipeline events`:新增 stage 化事件要求,终端和后续 GUI 必须消费事件。
|
||||
8. `Primary speaker endpointing`:新增本轮临时主说话人音色消失结束录音要求。
|
||||
9. `Low latency capture and first utterance preservation`:新增 ACK 后不额外丢弃正式问题、批量读帧、独立画像就绪阈值和快速主说话人端点要求。
|
||||
10. `Realtime partial transcript output`:新增录音期间 partial transcript 事件、终端显示和上下文隔离要求。
|
||||
|
||||
### 删除项
|
||||
|
||||
@@ -349,6 +358,7 @@ standby
|
||||
5. M5:真人验收反馈修正唤醒提示顺序、KWS 阈值和 hybrid VAD,并在门禁通过后提交。
|
||||
6. M6:Stage 化 pipeline、事件总线、TurnController、主说话人端点和文档验收分模块提交。
|
||||
7. M7:低延迟端点与首句保留修正完成后提交,保留真人 `run-live` 验收任务,不在用户确认前归档。
|
||||
8. M8:录音期间实时转写显示完成后提交,保留真人 `run-live` 验收任务,不在用户确认前归档。
|
||||
|
||||
估时:
|
||||
|
||||
|
||||
+9
-1
@@ -46,7 +46,15 @@ The live runtime SHALL preserve the start of the user's formal utterance after w
|
||||
- **THEN** capture SHALL close the utterance and proceed to STT without waiting for a second repeated question or generic VAD minimum duration
|
||||
|
||||
### Requirement: Realtime transcript terminal output
|
||||
The live runtime SHALL display the recognized user utterance text in the terminal after STT succeeds and before the LLM request is sent.
|
||||
The live runtime SHALL display recognized user utterance text in the terminal both during recording when partial transcript is available and after final STT succeeds before the LLM request is sent.
|
||||
|
||||
#### Scenario: User utterance partial is available during recording
|
||||
- **WHEN** the user is speaking after wake and the local realtime STT session produces a changed partial transcript
|
||||
- **THEN** the terminal output SHALL include a realtime transcript message containing the partial text before final STT completes
|
||||
|
||||
#### Scenario: Partial transcript is displayed
|
||||
- **WHEN** a partial transcript is emitted
|
||||
- **THEN** it SHALL be treated as user-visible feedback only and SHALL NOT be appended to the conversation context or sent to the LLM
|
||||
|
||||
#### Scenario: User utterance is transcribed
|
||||
- **WHEN** a live turn captures a user utterance and STT returns non-empty text
|
||||
|
||||
@@ -62,3 +62,11 @@
|
||||
- [x] 8.3 实现主说话人画像独立就绪阈值;前置条件:8.2 完成;验收标准:新增 `OWNER_SPEAKER_PROFILE_MIN_MS=120`,主说话人缺席结束不再被 `OWNER_VAD_MIN_DURATION_MS` 拖慢;测试要点:短首句、背景噪声和重复提问不合并;优先级:P0;预计:45 分钟。
|
||||
- [x] 8.4 补充配置文档、回归测试和门禁验证;前置条件:8.1 至 8.3 完成;验收标准:`.env.example`、README、配置显示和测试匹配新默认值;测试要点:compileall、unittest、security-check、model-check、device-check、OpenSpec strict;优先级:P0;预计:45 分钟。
|
||||
- [x] 8.5 提交“低延迟端点”模块;前置条件:8.4 门禁通过;验收标准:中文 commit 信息为 `[低延迟端点]:完成首句保留和快速结束修正,包含ACK缓冲策略、批量读帧和主说话人端点回归测试`,提交后 `git status --short` 为空;优先级:P0;预计:10 分钟。
|
||||
|
||||
## 9. 录音期间实时转写显示
|
||||
|
||||
- [x] 9.1 更新 OpenSpec 描述 partial transcript;前置条件:用户要求“实时显示用户说话转换的结果”;验收标准:proposal/design/spec/tasks 明确录音期间输出 `transcript_partial`,最终 `transcript_final` 仍用于 LLM;测试要点:OpenSpec strict;优先级:P0;预计:30 分钟。
|
||||
- [x] 9.2 实现 realtime transcript 事件和终端显示;前置条件:9.1 完成;验收标准:新增 `transcript_partial` 事件,终端输出 `实时转写:<文本>`,重复 partial 不刷屏;测试要点:事件顺序和 reporter 测试;优先级:P0;预计:45 分钟。
|
||||
- [x] 9.3 实现本地 streaming STT partial provider;前置条件:本地 STT 模型已由 `model-check` 覆盖;验收标准:`SherpaOnnxSttProvider` 支持 streaming session,cloud final ASR 模式下仍使用本地 streaming STT 做 partial;测试要点:fake session 与 metadata partial 单测;优先级:P0;预计:60 分钟。
|
||||
- [x] 9.4 接入 `VoiceAssistantPipeline` 捕获循环;前置条件:9.2 至 9.3 完成;验收标准:用户说话期间持续 feed 已开始录音的帧,partial 在 `speech_started` 后、`transcript_final` 前输出;测试要点:live runtime partial 顺序测试;优先级:P0;预计:45 分钟。
|
||||
- [x] 9.5 补充配置、README、门禁并提交;前置条件:9.1 至 9.4 完成;验收标准:新增 `OWNER_REALTIME_TRANSCRIPT_ENABLED=1`,compileall、unittest、security-check、model-check、device-check、OpenSpec strict 通过后中文 commit;优先级:P0;预计:45 分钟。
|
||||
|
||||
Reference in New Issue
Block a user