Use main voice if can't find voice tag or specified voice.

This commit is contained in:
SWivid
2024-10-21 11:53:44 +08:00
parent 2c0924378d
commit 77e00db01b

View File

@@ -150,10 +150,14 @@ def main_process(ref_audio, ref_text, text_gen, model_obj, remove_silence):
reg2 = r'\[(\w+)\]'
for text in chunks:
match = re.match(reg2, text)
if not match or voice not in voices:
voice = "main"
else:
if match:
voice = match[1]
else:
print("No voice tag found, using main.")
voice = "main"
if voice not in voices:
print(f"Voice {voice} not found, using main.")
voice = "main"
text = re.sub(reg2, "", text)
gen_text = text.strip()
ref_audio = voices[voice]['ref_audio']