Skip to content

Commit 737d101

Browse files
authored
Merge pull request #811 from FunAudioLLM/dev/lyuxiang.lx
update
2 parents 88f6a8e + d3b1a8e commit 737d101

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

cosyvoice/llm/llm.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,14 @@ def sampling_ids(
280280
sampling: int,
281281
ignore_eos: bool = True,
282282
):
283+
num_trials, max_trials = 0, 100
283284
while True:
284285
top_ids = self.sampling(weighted_scores, decoded_tokens, sampling)
285286
if (not ignore_eos) or (self.speech_token_size not in top_ids):
286287
break
288+
num_trials += 1
289+
if num_trials > max_trials:
290+
raise RuntimeError('sampling reaches max_trials {} and still get eos when ignore_eos is True, check your input!'.format(max_trials))
287291
return top_ids
288292

289293
@torch.inference_mode()

0 commit comments

Comments
 (0)