Repository navigation
feat(formatting): normalize quote marks in the final transcript - #52
Merged
Merged
Conversation
ASR engines hand back ASCII quote marks — Soniox in particular emits `"` around quoted speech and `'` in contractions — so dictated text arrived with straight quotes regardless of the surrounding language. Adds rule 3 to TranscriptCorrector: pair every double-quote mark across the dictation and re-emit it in the configured style. Language context is decided per dictation (any Han ideograph => Chinese), so a quoted English term inside a Chinese sentence takes Chinese marks; Latin-only text always gets curly marks. New `quoteStyle` preference picks the Chinese convention (「」 / “” / off), surfaced under 智能增强 → 文本格式. Lives in TranscriptCorrector, not TranscriptFormatter: the open/close call needs the whole final text, which a streamed fragment can't provide. The cost is that the HUD preview still shows straight quotes mid-dictation. Single quotes are only touched as apostrophes, and only with a word character on both sides — a one-sided test curls the tail of 'hi' while leaving its head straight, which reads worse than not touching it. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
ASR 引擎吐回来的是 ASCII 引号 —— Soniox 在转述句里给
",缩写里给'—— 所以听写出来的文本不管什么语境都是直引号。改动
TranscriptCorrector新增规则 3normalizeQuotes:跨整段配对每一个双引号,按配置的风格重新输出。什么是"action"→什么是「action」);纯拉丁文本永远用弯引号,不受设置影响。quoteStyle偏好:「」/“”/ 不处理,默认“”。设置界面在 智能增强 → 文本格式。don't→don’t,但只在两侧都是词内字符时才转。单边判断会把'hi'变成'hi’(头直尾弯),比不动更难看;代价是所有格复数students'保持 ASCII 撇号。他说 "你好"→他说「你好」)。TranscriptFormatter.tightenCJKSpaces故意不认弯引号(它们同时是英文标点),所以这个 trim 只能在已知语境的这一层做。为什么放在 corrector 而不是 formatter
开引号还是闭引号的判断需要整段最终文本,流式片段给不了。代价是听写过程中 HUD 预览里仍然是直引号,只有最终注入的文本被规范化。
已知天花板
enable_punctuation/enable_text_post_process都已开启也没用。所以「」只在走 Soniox(中英混合)时才有素材可规范。这是引擎限制,不是格式化规则能补的。验证
make install后现场听写验证:He said, "I don't care about distinction."→He said, “I don’t care about distinction.”他说,I don't care about distinction,我觉得他说得挺对的。→他说:「I don’t care about distinction,」我觉得他说得挺对的。🤖 Generated with Claude Code