Skip to content

feat(remote-input): 远程输入可选转发本会话的实时识别文字 - #1147

Open
Francis-Zxp wants to merge 1 commit into
Open-Less:betafrom
Francis-Zxp:feat/remote-input-live-transcript
Open

Francis-Zxp wants to merge 1 commit into
Open-Less:betafrom
Francis-Zxp:feat/remote-input-live-transcript

Conversation

@Francis-Zxp

Copy link
Copy Markdown

摘要

无关联 issue。

远程输入(WebSocket)目前只把本会话的最终润色结果发给客户端。识别过程中的实时文字已经由 dictation_engine.rs 的 TranscriptProgressForwarder 按会话发布为 TranscriptDelta,但 backend_event_to_phone 没有转发它。本 PR 让客户端在 hello 帧里用 "partials": true 显式请求后,收到本会话的实时文字。

背景:我在做一个通过远程输入接口接入 OpenLess 的 Windows 翻页笔语音工具,希望在自己的悬浮窗里边说边显示识别文字,现在只能等最终结果。

修复 / 新增 / 改进

  • remote_server/mod.rs:backend_event_to_phone 新增 wants_partials 参数。为真时,把本会话的 TranscriptDelta 转发为 {"type":"partial","text":…,"offset":…,"final":…}。offset 的含义与 TranscriptAccumulator::apply 一致:从第 offset 个字符起替换。
  • 新增 parse_hello_partials,与 parse_hello_pin 并列,只读取 hello 帧里这个可选布尔字段。
  • 所有权规则不变:仍然只转发本连接自己开启的会话,其他会话(本机听写、其他手机)的实时文字不会转发;实时文字也不会结束会话所有权。

兼容

  • 不包含:自带手机网页(assets/remote-input)的界面改动。
  • 对现有用户 / 本地环境 / 构建流程的影响:无。
    • 没有发送 "partials": true 的客户端(包括自带手机页面)收到的消息完全不变。
    • 旧版 OpenLess 会忽略 hello 里的这个字段,客户端可以无条件发送。
    • 开启“停止后再识别”时,引擎本来就不发布中间结果,客户端只会收到最终的 final 文字和原有的 result。

测试计划

  • 命令:cargo test --manifest-path src-tauri/Cargo.toml --lib remote_server(Windows 11,Rust 1.95)。按 CI 的做法,先运行了 scripts/ci-disable-macos-qwen3.mjs 和 scripts/prepare-windows-sherpa.ps1。
  • 结果:21 passed; 0 failed,其中包括新增的 websocket_forwards_live_transcript_only_when_asked_and_only_for_the_owned_session。它覆盖三种情况:未请求时不发送;其他会话不发送;本会话按 offset 发送,且不结束所有权。
  • 证据路径:在 Windows 上,lib 测试可执行文件因为没有 Common-Controls v6 清单,启动时会报 STATUS_ENTRYPOINT_NOT_FOUND(CI 在 Windows 上也只做 --no-run)。本地用 mt.exe 给测试可执行文件嵌入清单后运行,上面的结果就来自这次运行。
  • rustfmt --edition 2021 已格式化改动文件。

客户端在 hello 帧中发送 "partials": true 后,本连接自己开启的会话的
TranscriptDelta 会作为 {"type":"partial","text","offset","final"} 转发;
未请求的客户端(包括自带手机页面)消息不变,所有权规则不变。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant