Skip to content

减少语音句尾丢字,修复空格滑动光标分隔符与九键拼音栏锁争用 - #151

Draft
Slacker-LLC wants to merge 1 commit into
mainfrom
ccr-0eb3ba26-ytxlxu
Draft

Slacker-LLC wants to merge 1 commit into
mainfrom
ccr-0eb3ba26-ytxlxu

Conversation

@Slacker-LLC

Copy link
Copy Markdown
Owner

Summary

静态审查(语音、空格滑动光标、九键拼音索引)后修的几处问题。未在真机验证,见下方“未验证”。

语音丢字

  • 松手后原来立即 record.stop(),采集循环按 running 退出,AudioRecord 内部缓冲里没读出的最后一块被丢弃(Windows 的 waveInReset 会把已录缓冲全部交还,没有这个问题)。现在松手后再录 200ms,由采集线程自己 stop(),再用 READ_NON_BLOCKING 读空剩余;外部 stop 只作看门狗(再等 400ms)。
  • Paraformer 收尾静音 0.3s → 0.66s,与 sherpa-onnx 官方 online-decode-files.py 一致(Windows 仓库同步,另一个 PR)。
  • 语音松手后等转写期间,空格滑动不再触发 prepareForManualInput(它会取消整段识别)。

空格滑动光标

  • 预编辑里的 ' 和空格不再占一格(ni|'hao 与 ni'|hao 是同一位置),逻辑在 PreeditCursorPolicy。

九键拼音栏

  • NineKeyLocalDecoder 的只读查询(trie 与各表在 init 后不再写入)去掉 @Synchronized,拼音栏在主线程的查询不再排在候选线程 resolve() 后面;readingOptions 加 16 项 LRU。

Affected areas

  • InputConnection, editor behavior
  • Keyboard layout, insets, floating keyboard
  • Voice model, audio permission
  • Build, tests or documents

Verification

  • :app:testDebugUnitTest:612 项,611 通过。唯一失败 VoiceModelTrustPolicyTest.bundledCatalogTrustsOnlyExactOfficialManifestAndLayout 因为本环境只拉了 app/libs 的 LFS,模型文件还是指针,与本改动无关。
  • :app:lintDebug
  • :app:assembleDebug
  • Real input method regression (if it applies)
  • git diff --check

新增测试:PreeditCursorPolicyTest、NineKeyDecoderThreadingTest(持有解码器锁时只读查询仍能返回)、LocalAudioVoiceBackendTest 的残余排空用例。

未验证(需真机)

  • 200ms 宽限与残余排空对句尾丢字的实际改善量;stop() 之后 read() 能否取出残留音频因机型而异。对照现有日志 captureFinished … capturedSamples 与 captureResidual samples=。
  • 0.66s 静音是否改善流式 Paraformer 末尾字,建议同一批录音 A/B。
  • 九键在主线程跑 resolveNineKey 的耗时(OpenImeNineKeyPerf 日志)未测,本 PR 没动这部分。

Change log and version

  • I added each user-visible change to [Unreleased] in CHANGELOG.md.
  • I did not change VERSION.
  • The PR title states the result.

Privacy and delivery

  • The change has no passwords, clipboard content, recordings, device logs or personal paths.
  • The change keeps the source and license of each model, dictionary and third-party file.
  • No change to user data or settings formats.

Generated by Claude Code

- 语音:松手后麦克风再录 200ms,由采集线程自己 stop() 并用 READ_NON_BLOCKING
  读空录音器剩余音频;外部 stop 只作看门狗。此前松手即停且循环按 running 退出,
  录音器内部缓冲里最后一块被丢弃。
- 语音:Paraformer 收尾静音 0.3s → 0.66s,与 sherpa-onnx 官方 Python 示例一致。
- 空格滑动:预编辑里的 ' 和空格不占一格;语音等待结果期间不处理滑动,
  否则 prepareForManualInput 会取消并丢掉整句转写。
- 九键:解码器的只读查询去掉 @synchronized,拼音栏主线程查询不再排在
  候选线程的 resolve() 后面;readingOptions 加 16 项 LRU,重复刷新取缓存。

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012wKchue4wWKw2WmV6Kcw8S
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.

2 participants