lyuxiang.lx 4 months ago
parent
commit
f21c4764ec
2 changed files with 27 additions and 27 deletions
  1. 1 1
      cosyvoice/llm/llm.py
  2. 26 26
      cosyvoice/utils/common.py

+ 1 - 1
cosyvoice/llm/llm.py

@@ -604,7 +604,7 @@ class Qwen2LM(TransformerLM):
                                                       masks=torch.tril(torch.ones((1, seq_len, seq_len), device=lm_input.device)).to(torch.bool),
                                                       cache=cache)
             logp = self.llm_decoder(y_pred[:, -1]).log_softmax(dim=-1)
-            top_ids = self.sampling_ids(logp.squeeze(dim=0), out_tokens, sampling, ignore_eos=False).item()
+            top_ids = self.sampling_ids(logp.squeeze(dim=0), out_tokens, sampling, ignore_eos=False)
             out_tokens.append(top_ids)
             if top_ids >= self.speech_token_size:
                 if top_ids == self.eos_token:

+ 26 - 26
cosyvoice/utils/common.py

@@ -25,32 +25,32 @@ import torch
 
 IGNORE_ID = -1
 
-instruct_list = ["You are a helpful assistant. 请用广东话表达。<endofprompt>",
-                 "You are a helpful assistant. 请用东北话表达。<endofprompt>",
-                 "You are a helpful assistant. 请用甘肃话表达。<endofprompt>",
-                 "You are a helpful assistant. 请用贵州话表达。<endofprompt>",
-                 "You are a helpful assistant. 请用河南话表达。<endofprompt>",
-                 "You are a helpful assistant. 请用湖北话表达。<endofprompt>",
-                 "You are a helpful assistant. 请用湖南话表达。<endofprompt>",
-                 "You are a helpful assistant. 请用江西话表达。<endofprompt>",
-                 "You are a helpful assistant. 请用闽南话表达。<endofprompt>",
-                 "You are a helpful assistant. 请用宁夏话表达。<endofprompt>",
-                 "You are a helpful assistant. 请用山西话表达。<endofprompt>",
-                 "You are a helpful assistant. 请用陕西话表达。<endofprompt>",
-                 "You are a helpful assistant. 请用山东话表达。<endofprompt>",
-                 "You are a helpful assistant. 请用上海话表达。<endofprompt>",
-                 "You are a helpful assistant. 请用四川话表达。<endofprompt>",
-                 "You are a helpful assistant. 请用天津话表达。<endofprompt>",
-                 "You are a helpful assistant. 请用云南话表达。<endofprompt>",
-                 "You are a helpful assistant. Please say a sentence as loudly as possible.<endofprompt>",
-                 "You are a helpful assistant. Please say a sentence in a very soft voice.<endofprompt>",
-                 "You are a helpful assistant. 请用尽可能慢地语速说一句话。<endofprompt>",
-                 "You are a helpful assistant. 请用尽可能快地语速说一句话。<endofprompt>",
-                 "You are a helpful assistant. 请非常开心地说一句话。<endofprompt>",
-                 "You are a helpful assistant. 请非常伤心地说一句话。<endofprompt>",
-                 "You are a helpful assistant. 请非常生气地说一句话。<endofprompt>",
-                 "You are a helpful assistant. 我想体验一下小猪佩奇风格,可以吗?<endofprompt>",
-                 "You are a helpful assistant. 你可以尝试用机器人的方式解答吗?<endofprompt>"]
+instruct_list = ["You are a helpful assistant. 请用广东话表达。<|endofprompt|>",
+                 "You are a helpful assistant. 请用东北话表达。<|endofprompt|>",
+                 "You are a helpful assistant. 请用甘肃话表达。<|endofprompt|>",
+                 "You are a helpful assistant. 请用贵州话表达。<|endofprompt|>",
+                 "You are a helpful assistant. 请用河南话表达。<|endofprompt|>",
+                 "You are a helpful assistant. 请用湖北话表达。<|endofprompt|>",
+                 "You are a helpful assistant. 请用湖南话表达。<|endofprompt|>",
+                 "You are a helpful assistant. 请用江西话表达。<|endofprompt|>",
+                 "You are a helpful assistant. 请用闽南话表达。<|endofprompt|>",
+                 "You are a helpful assistant. 请用宁夏话表达。<|endofprompt|>",
+                 "You are a helpful assistant. 请用山西话表达。<|endofprompt|>",
+                 "You are a helpful assistant. 请用陕西话表达。<|endofprompt|>",
+                 "You are a helpful assistant. 请用山东话表达。<|endofprompt|>",
+                 "You are a helpful assistant. 请用上海话表达。<|endofprompt|>",
+                 "You are a helpful assistant. 请用四川话表达。<|endofprompt|>",
+                 "You are a helpful assistant. 请用天津话表达。<|endofprompt|>",
+                 "You are a helpful assistant. 请用云南话表达。<|endofprompt|>",
+                 "You are a helpful assistant. Please say a sentence as loudly as possible.<|endofprompt|>",
+                 "You are a helpful assistant. Please say a sentence in a very soft voice.<|endofprompt|>",
+                 "You are a helpful assistant. 请用尽可能慢地语速说一句话。<|endofprompt|>",
+                 "You are a helpful assistant. 请用尽可能快地语速说一句话。<|endofprompt|>",
+                 "You are a helpful assistant. 请非常开心地说一句话。<|endofprompt|>",
+                 "You are a helpful assistant. 请非常伤心地说一句话。<|endofprompt|>",
+                 "You are a helpful assistant. 请非常生气地说一句话。<|endofprompt|>",
+                 "You are a helpful assistant. 我想体验一下小猪佩奇风格,可以吗?<|endofprompt|>",
+                 "You are a helpful assistant. 你可以尝试用机器人的方式解答吗?<|endofprompt|>"]
 
 
 def pad_list(xs: List[torch.Tensor], pad_value: int):