mirror of
https://github.com/modelscope/FunASR.git
synced 2026-10-12 02:19:18 +00:00
* Fix #2839: initialize punc_res before conditional to prevent UnboundLocalError When punc_model is None or not provided, punc_res was only assigned inside the `if self.punc_model is not None:` block. Downstream code paths (punc_segment speaker diarization and sentence_timestamp) accessed punc_res unconditionally, causing UnboundLocalError. Changes: - Initialize punc_res = None before the conditional block - Add punc_res is None guard in punc_segment path with error log - Add punc_res is None guard in sentence_timestamp path with warning log - Add unit tests covering punc_model=None, empty punc_model, and normal flow Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Lidang-Jiang <[email protected]> * fix: update docstring to only mention punc_model=None case The tests only cover the None case, not the empty string case. Update the module docstring to match actual test coverage. Signed-off-by: Lidang-Jiang <[email protected]> --------- Signed-off-by: Lidang-Jiang <[email protected]>