update and fix

This commit is contained in:
Xiong Wang
2026-01-30 10:58:02 +08:00
parent 9567667698
commit b248b4aa94
3 changed files with 19 additions and 9 deletions

View File

@ -733,8 +733,18 @@ class Qwen3ASRModel:
prefix = ""
else:
cur_ids = self.processor.tokenizer.encode(state._raw_decoded)
end_idx = max(1, len(cur_ids) - int(state.unfixed_token_num))
prefix = self.processor.tokenizer.decode(cur_ids[:end_idx])
k = int(state.unfixed_token_num)
while True:
end_idx = max(0, len(cur_ids) - k)
prefix = self.processor.tokenizer.decode(cur_ids[:end_idx]) if end_idx > 0 else ""
try:
prefix.encode("utf-8").decode("utf-8")
break
except UnicodeError:
if end_idx == 0:
prefix = ""
break
k += 1
prompt = state.prompt_raw + prefix