Spaces:
Running
on
T4
Running
on
T4
Improve the multilingual parser
Browse files
app.py
CHANGED
@@ -32,9 +32,14 @@ text_examples = [
|
|
32 |
]
|
33 |
|
34 |
def parse_multilingual_text(input_text):
|
35 |
-
pattern = r"
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
@spaces.GPU(enable_queue=True)
|
40 |
def generate_segment_audio(text, lang, speaker_audio, pipe):
|
|
|
32 |
]
|
33 |
|
34 |
def parse_multilingual_text(input_text):
|
35 |
+
pattern = r"(?:<(\w+)>)|([^<]+)"
|
36 |
+
cur_lang = 'en'
|
37 |
+
segments = []
|
38 |
+
for i, (lang, txt) in enumerate(re.findall(pattern, input_text)):
|
39 |
+
if lang: cur_lang = lang
|
40 |
+
else: segments.append((cur_lang, f" {txt} ")) # add spaces to give it some time to switch languages
|
41 |
+
if not segments: return [("en", "")]
|
42 |
+
return segments
|
43 |
|
44 |
@spaces.GPU(enable_queue=True)
|
45 |
def generate_segment_audio(text, lang, speaker_audio, pipe):
|