Files
FunASR/tests
Lidang Jiang 8dc6ceabcf Fix #2839: initialize punc_res before conditional to prevent UnboundLocalError (#2840)
* 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]>
2026-05-19 16:30:00 +08:00
..
2024-04-24 16:03:38 +08:00
2024-04-24 16:03:38 +08:00
2024-04-24 16:03:38 +08:00