feat: enhance Soniox ASR with sentence termination handling#2196
Conversation
Code Review — Soniox ASR sentence terminationThanks for this. The sentence-boundary gating is a nice addition and the test suite is genuinely thorough (parametrized detector unit tests + end-to-end batch tests). A few things worth addressing before merge. Bugs / correctness1. Deferred vendor-final tokens are dropped on finalize (potential data loss). 2. README documents a config key that doesn't exist. Dead codeThree new methods are defined but never called anywhere:
These add ~35 lines and are untested. Recommend removing them unless a follow-up wires them in. Minor
Performance
TestsGood coverage of the detector and the happy paths. Two gaps to consider:
|
PR Review: feat: enhance Soniox ASR with sentence termination handlingNice work. This adds a Potential bugs1. Deferred final tokens appear to be dropped on finalize (possible data loss). 2. Translations are emitted once per ASR result in a mixed batch. Code quality3. 4. 5. Backward compatibility of the new Minor
TestsStrong coverage on Overall the logic is solid and well-tested; the finalize-drop behavior in (1) is the one item I'd want resolved or confirmed before merge. |
| # path: "12.Hello" is a sentence boundary after "12.", while "12.5" | ||
| # is a decimal and must wait. If the next char is unknown ("12."), | ||
| # stay conservative and defer. | ||
| digit_period_decision = self._digit_period_boundary_decision( |
There was a problem hiding this comment.
pysbd can't handle this?
There was a problem hiding this comment.
Because soniox is outputted in a streaming manner through tokens.
For both "12.Hello" and "12.5", it is possible to first receive the token "12.", and then receive the next token. When receiving "12.", only the currently existing token and the next token can be used for judgment.
Currently, pysbd only focuses on making judgments based on Mr., which is difficult to cover with rules
| asr_results: List[ASRResult], | ||
| translation_tokens: List[SonioxTranslationToken], | ||
| ) -> None: | ||
| """Publish one asr_result per segment, then asr_results batch.""" |
There was a problem hiding this comment.
add some comments here since it's for backward compatibility.
Code Review: Soniox ASR sentence termination handlingThanks for this — the Potential bugs1. Swapped comment vs. logic in if self.config is None or self.config.holding_mode != HoldingMode.SENTENCE_TERMINATOR:
# In SENTENCE_TERMINATOR mode, asr_results are sent in segments... <-- but this branch is the NON-sentence_terminator path
if result.final:
await self._send_translation_results(...)
else:
# other modes, send translation for each segment <-- but this is the SENTENCE_TERMINATOR branch
await self._send_translation_results(...)The behavior may well be intentional, but the comments describe the opposite branch they sit in. Please fix the comments (or the logic) so the next reader isn't misled. The docstring above says "translation is sent only for final segments," which also conflicts with the 2. 3. Behavior change to flag4. "stable": is_final, # was: token.is_finalThis changes per-word Robustness5. pySBD probe correctness ( 6. No graceful fallback if Minor7. 8. 9. Version bump 0.4.5 → 0.5.2 skips 0.5.0/0.5.1 — fine if intentional, just noting. TestsCoverage is excellent — mixed-language batches, deferred flush on finalize, abbreviation handling, decimals, CJK ellipsis, and non-zh/en passthrough are all exercised. Two gaps worth adding:
Overall solid work. The main blockers are the misleading comments (#1) and confirming the |
ee9fd3f to
d08fcea
Compare
PR Review: Enhance Soniox ASR with sentence termination handlingThanks for this — the Behavioral changes that reach modes beyond
|
No description provided.