SOTA Open Source TTS
Fix top-1 guard in logits_to_probs for batched logits (#1326)
Rishabh Jainc164eb5a4417
diff --git a/fish_speech/models/text2semantic/inference.py b/fish_speech/models/text2semantic/inference.pyindex 59653d5..63b977c 100644--- a/fish_speech/models/text2semantic/inference.py+++ b/fish_speech/models/text2semantic/inference.py@@ -63,7 +63,7 @@ def logits_to_probs(indices = torch.arange(sorted_logits.shape[-1], device=sorted_logits.device)top_k_mask = indices >= top_ksorted_indices_to_remove = (cum_probs > top_p) | top_k_mask- sorted_indices_to_remove[0] = False # 单元素修改问题不大,或者写成 | (indices != 0)+ sorted_indices_to_remove[..., 0] = False # keep the top-1 token, per rowindices_to_remove = sorted_indices_to_remove.scatter(dim=-1, index=sorted_indices, src=sorted_indices_to_remove