Simplify i18n text and remove trailing spaces

This commit is contained in:
starylan 2025-02-12 01:47:32 +08:00
parent 4748f1a6b0
commit 9ce83c8eea
2 changed files with 127 additions and 130 deletions

View File

@ -744,7 +744,7 @@ class TTS:
if path in [None, ""]:
continue
if not os.path.exists(path):
print(i18n("音频文件不存在,跳过:{}").format(path))
print(i18n("音频文件不存在,跳过:"), path)
continue
self.prompt_cache["refer_spec"].append(self._get_ref_spec(path))
@ -787,7 +787,7 @@ class TTS:
precision=self.precision
)
else:
print(i18n("############ 切分文本 ############"))
print(f'############ {i18n("切分文本")} ############')
texts = self.text_preprocessor.pre_seg_text(text, text_lang, text_split_method)
data = []
for i in range(len(texts)):
@ -797,7 +797,7 @@ class TTS:
def make_batch(batch_texts):
batch_data = []
print(i18n("############ 提取文本Bert特征 ############"))
print(f'############ {i18n("提取文本Bert特征")} ############')
for text in tqdm(batch_texts):
phones, bert_features, norm_text = self.text_preprocessor.segment_and_extract_feature_for_text(text, text_lang, self.configs.version)
if phones is None:

View File

@ -56,11 +56,11 @@ class TextPreprocessor:
self.device = device
def preprocess(self, text:str, lang:str, text_split_method:str, version:str="v2")->List[Dict]:
print(i18n("############ 切分文本 ############"))
print(f'############ {i18n("切分文本")} ############')
text = self.replace_consecutive_punctuation(text)
texts = self.pre_seg_text(text, lang, text_split_method)
result = []
print(i18n("############ 提取文本Bert特征 ############"))
print(f'############ {i18n("提取文本Bert特征")} ############')
for text in tqdm(texts):
phones, bert_features, norm_text = self.segment_and_extract_feature_for_text(text, lang, version)
if phones is None or norm_text=="":
@ -239,6 +239,3 @@ class TextPreprocessor:
pattern = f'([{punctuations}])([{punctuations}])+'
result = re.sub(pattern, r'\1', text)
return result