Commit
·
8bf7a01
1
Parent(s):
3b279c1
check and remove consecutive speaker ids
Browse files- inference.py +9 -1
inference.py
CHANGED
@@ -307,8 +307,16 @@ class StyleTTS2(torch.nn.Module):
|
|
307 |
text = re.sub(lang_pattern, replacement_func, text)
|
308 |
|
309 |
texts = re.split(r'(\[id_\d+\])', text) #split the text by speaker ids while keeping the ids.
|
310 |
-
if len(texts) <= 1:
|
311 |
texts.insert(0, default_speaker)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
312 |
texts = list(filter(lambda x: x != '', texts))
|
313 |
|
314 |
print("Generating Audio...")
|
|
|
307 |
text = re.sub(lang_pattern, replacement_func, text)
|
308 |
|
309 |
texts = re.split(r'(\[id_\d+\])', text) #split the text by speaker ids while keeping the ids.
|
310 |
+
if len(texts) <= 1 or bool(re.match(r'(\[id_\d+\])', texts[0])): #Add a default speaker
|
311 |
texts.insert(0, default_speaker)
|
312 |
+
curr_id = None
|
313 |
+
for i in range(len(texts)): #remove consecutive ids
|
314 |
+
if bool(re.match(r'(\[id_\d+\])', texts[i])):
|
315 |
+
if texts[i]!=curr_id:
|
316 |
+
curr_id = texts[i]
|
317 |
+
else:
|
318 |
+
texts[i] = ''
|
319 |
+
del curr_id
|
320 |
texts = list(filter(lambda x: x != '', texts))
|
321 |
|
322 |
print("Generating Audio...")
|