Files
CyberGril/docs/rework/hel879/voice-seam-interfaces.md
T
zonggongandmultica-agent 7c73d392b9 HEL-879 rework materials: hatchling cache correction with the offline mem0ai wheel actually built from the fixed source (sha256 698284b6..., zero downloads/installs, no 3.10 mixing, recorded in release-artifacts.json), hel895 release doc §0 now separates the historical HEL-895/896 candidate from the current hel-879-assembly candidate and §4/§5 carry the v3 snapshot semantics, budget §6.2.4 amended - a sealed library is never reopened by raising total_requests (contradiction removed), runbook §3.3/3.5/3.6/4.4/4.5 corrected (bounded cleanup ledger replaces the unproven rooms-die-naturally claim; assistant_interim kind; real-but-default-off proactive seam; single-owner dual launcher), one comment-only correction in web/src/voice/session.ts removing the unproven server-auto-cleanup claim (no logic/style change; CSS and JS bundle hashes byte-stable), CG-011 + her incremental subtitles now have a real minimal backend seam (voice/seam.py + worker/llm_chat_api wiring, proactive default off) with the precise frontend interface and acceptance list in docs/rework/hel879/voice-seam-interfaces.md, real-SDK check extended to 10 items (worker callback path on real SpeechHandle/SpeechCreatedEvent; interim seam through real LLMStream) and re-run on .12 ALL PASS, handoff-HEL-879.json appended with the rework scope; regression at this head: pytest 341/341, ruff clean except 1 pre-existing error identical at 7f0a739, web typecheck 0 errors / lint 0 errors 1 pre-existing warning / vitest 88/88 / build passes (CSS index-BpZaybfD.css unchanged), voice chain 8/8, budget split 10/10, release offline R1-R7, http pagination 7/7, real-service browser 9/9 with zero non-loopback outbound, pinned-SDK 16/16+12/12+6/6+7/7+12/12, requirements checks 4/4 (origin/main and c121c42, each with/without handoff)
Co-authored-by: multica-agent <github@multica.ai>
2026-10-27 04:27:04 +08:00

5.4 KiB
Raw Blame History

HEL-879 · 语音接缝接口与验收(交原视觉作者接线;总工不改已认可 web/src 视觉)

背景:总管独立复核指出「CG-011 语音主动开口 no-op、她的增量字幕缺失」是 实现缺口,不能归为「等音色/预算就能自动完成」。本文件给出后台已落地的 最小接缝、前端需要补的精确接口与验收标准。代码基点:分支 hel-879-assembly(见交付评论精确 head);后台实现 src/cybergril/voice/seam.py + worker.py 接线。

A. 她的增量回复字幕(assistant_interim)

现状与缺口

  • 用户侧 ASR 字幕已齐:interim(ASR 草稿)与 user_final(纠错终稿)在 web/src/voice/session.ts 已渲染(现有 interim 分支当「听到用户在说」处理, 不能复用来渲染她的回复——那是另一个语义)。
  • 缺的是她的回复在 TTS 首包前/播放中的增量文字。后台现已补齐:worker 把 /api/chat SSE 的每个 delta 累积后发布到同一 cg.subtitle 通道。

后台已交付(无需前端改动即生效的数据)

  • 数据通道:topic cg.subtitle(不变)。
  • 新 kind:assistant_interim,role: "assistant",text 为截至当前的完整 回复文本(替换语义,同用户 interim;发布时机=SSE 分片到达,先于/伴随 TTS)。
  • 既有 kind 不变:assistant_final(已落库的完整回复,播放完成且未打断后发)、 error(φ 原句,未落库)、interim/user_final(用户侧)。
  • fail-closed 语义不变:打断/失败/无回执的轮只有 interim,不会有 final—— 前端必须把无 final 收尾的 interim 按「这轮没有成为她的正式回复」处理。

前端需补(原视觉作者;具体视觉由其定)

  1. web/src/voice/session.ts 字幕分支:新增 assistant_interim 处理(当前 if (s.kind === 'interim') 只覆盖用户草稿)。
  2. 渲染位置/样式:与 assistant_final 同一气泡位(建议替换式过渡),与用户 heard 视觉可区分;不进入正式聊天记录(只有 final 落库)。
  3. 收尾规则:assistant_final 到达 → interim 消失、final 生效;error 到达 → interim 消失、按现有 error 呈现;被打断(无任何收尾)→ 下一次 interim 或 新轮开始时清掉;挂断 → 清掉。

验收(离线可测,无需真实通话)

  • 用假 LiveKit/假音频脚本回放 cg.subtitle 序列 interim(user) → user_final → assistant_interim("她在") → assistant_interim("她在打字中") → assistant_final("她在打字中。"), 页面按序呈现且 interim 被 final 原子替换。
  • 打断负例:assistant_interim 后直接新的 interim(user)(无 final/error), 她的 interim 残影不越过新用户轮。
  • φ 负例:assistant_interim → error,error 文案呈现且不落正式记录。
  • 全程零新增权限申请、零非回环出站(沿用 HEL-896 浏览器检查口径)。

B. CG-011 语音主动开口(最小接缝,默认关闭)

后台已交付

  • worker.py _maybe_open_proactive(真实代码路径,CYBERGRIL_PROACTIVE_VOICE=1 才启用;默认关,等接线卡与呈现批准):
    • 数据来源:与文字收件箱同一 GET /api/messages(ChatApiClient.recent_messages), 只选服务端已落库(proactive=1、role=companion、status=sent、非空、 本房间未念过)的行,最新优先,每会话 ≤1 条(PROACTIVE_PER_SESSION)。
    • 播报:session.say(text, allow_interruptions=True)——可被用户打断; 无新模型调用、无第二人格、无第二条回执通道(文字回执规则独立且已存在)。
    • 失败 fail-closed:接缝任何异常只记日志跳过,不影响会话开启。
  • 选择逻辑独立在 seam.py pick_proactive/pending_proactive(离线可测, tests/test_voice_rework_hel879.py 三例覆盖)。

前端/接线卡需定(原视觉作者 + 总管,经用户批准后启用)

  1. 入口呈现:她主动开口时页面如何呈现(字幕走 assistant_final 同位? 是否复用留言卡「回她」入口语义?未读标记如何联动——worker 不代标已读, 阅读态仍归页面)。
  2. 节奏:会话开启后何时念(现在=开启即查一次、每会话最多一条);是否需要在 会话中轮询新 proactive(后续卡,不默记完成)。
  3. 打断呈现:用户开口打断她的主动播报时,字幕按打断负例处理(无 final 收尾)。

验收(启用后)

  • 预置一条落库 proactive 行 → 开语音会话 → 她原文念出该行(与文字收件箱 同一行、一字不差),字幕按定稿呈现。
  • 播报中用户开口 → 立即被打断、无残音;该行不被标记已读(除非用户在页面 读它)、无回执伪造。
  • 无 proactive 行 → 会话正常开启,静默。
  • API 不可达 → 接缝跳过,语音会话不受影响。

边界

  • 本文件只交接口与验收;总工未改任何已认可 web/src 视觉(本卡 web/src 仅 勘正 session.ts 一处无证据注释,无逻辑/样式改动,diff 见交付评论)。
  • R5 真机验收(≥3 轮、1 秒打断、停麦无残音、可信 HTTPS/WSS、D1 音色、有限 预算)仍待主卡集中批准,接缝通过≠R5 完成。