mirror of
https://github.com/FunAudioLLM/CosyVoice.git
synced 2026-02-04 17:39:25 +08:00
Update frontend.py
Fix the bug in handling anomalies for synthetic text ending with Chinese and English commas.
This commit is contained in:
@@ -20,6 +20,7 @@ from typing import Callable
|
|||||||
import torchaudio.compliance.kaldi as kaldi
|
import torchaudio.compliance.kaldi as kaldi
|
||||||
import torchaudio
|
import torchaudio
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import inflect
|
import inflect
|
||||||
try:
|
try:
|
||||||
import ttsfrd
|
import ttsfrd
|
||||||
@@ -110,6 +111,7 @@ class CosyVoiceFrontEnd:
|
|||||||
text = text.replace(".", "、")
|
text = text.replace(".", "、")
|
||||||
text = text.replace(" - ", ",")
|
text = text.replace(" - ", ",")
|
||||||
text = remove_bracket(text)
|
text = remove_bracket(text)
|
||||||
|
text = re.sub(r'[,,]+$', '。', text)
|
||||||
texts = [i for i in split_paragraph(text, partial(self.tokenizer.encode, allowed_special=self.allowed_special), "zh", token_max_n=80,
|
texts = [i for i in split_paragraph(text, partial(self.tokenizer.encode, allowed_special=self.allowed_special), "zh", token_max_n=80,
|
||||||
token_min_n=60, merge_len=20,
|
token_min_n=60, merge_len=20,
|
||||||
comma_split=False)]
|
comma_split=False)]
|
||||||
|
|||||||
Reference in New Issue
Block a user