Repository navigation
fix(postprocess): keep a trailing @@ piece instead of dropping it - #3836
Open
ANDROIDHASSAN wants to merge 1 commit into
Open
ANDROIDHASSAN wants to merge 1 commit into
ANDROIDHASSAN wants to merge 1 commit into
Conversation
A token list that ends on a BPE piece (a streaming chunk that ends inside a word) left the piece in word_item and never emitted it.
This branch has not been deployed
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.
Problem
sentence_postprocesscollects a BPE word inword_itemuntil a token without@@closes it. When the token list ends on a@@piece, nothing closes it and the piece is dropped:Streaming Paraformer hits this every time a word spans two chunks:
paraformer_streaming/model.pyandfunasr_onnx/paraformer_online_bin.pypostprocess each chunk on its own, so the first part of that word disappears from the transcript.Fix
After the loop, a non-empty
word_itemis added as a word, with the[begin, end]already tracked for it when timestamps are given. The same 6 lines go into all three copies ofpostprocess_utils.py(funasr, funasr_onnx, funasr_torch). Token lists that end on a complete word are unchanged.Tests
Added to
tests/test_sentence_postprocess_timestamps.py, over all three copies:["hello", "wor@@"],["你", "好", "wor@@"], and the timestamped["hello", "wor@@", "l@@"]→["hello", "worl"],[[0, 100], [100, 300]].test_postprocess_hotwords.py,test_rich_transcription_postprocess.py,test_sentence_postprocess_timestamps.py): 26 passed, 6 skipped (the fuzzy hotword tests, pypinyin/rapidfuzz not installed here; same 6 skipped on main).Scope
A
@@piece followed by a Chinese character in mixed text (["hel@@", "你"]) is still mishandled the way it is today; that is a different case and not changed here.