diff --git a/cosyvoice/utils/common.py b/cosyvoice/utils/common.py index 5d307ae..3f235a6 100644 --- a/cosyvoice/utils/common.py +++ b/cosyvoice/utils/common.py @@ -139,6 +139,7 @@ def ras_sampling(weighted_scores, decoded_tokens, sampling, top_p=0.8, top_k=25, top_ids = nucleus_sampling(weighted_scores, top_p=top_p, top_k=top_k) rep_num = (torch.tensor(decoded_tokens[-win_size:]).to(weighted_scores.device) == top_ids).sum().item() if rep_num >= win_size * tau_r: + weighted_scores[top_ids] = -float('inf') top_ids = random_sampling(weighted_scores, decoded_tokens, sampling) return top_ids