From f2ddcbe7f923e4ea153cc3a64a36987b7fa93a4b Mon Sep 17 00:00:00 2001 From: "lyuxiang.lx" Date: Wed, 4 Feb 2026 11:44:39 +0800 Subject: [PATCH] fix ras --- cosyvoice/utils/common.py | 1 + 1 file changed, 1 insertion(+) 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