Spaces:
Running
Running
p
commited on
Commit
·
7b6aa43
1
Parent(s):
a82b119
number to word before punct replacement
Browse files
app.py
CHANGED
@@ -43,8 +43,7 @@ tts_models["mya"] = mya_path
|
|
43 |
with open("lang_code.json") as f:
|
44 |
lang_codes = json.load(f, object_pairs_hook=OrderedDict)
|
45 |
|
46 |
-
lang_codes = {
|
47 |
-
key + " (" + lang_codes[key] + ")": lang_codes[key] for key in lang_codes}
|
48 |
# Extract language names
|
49 |
language_names = list(lang_codes.keys())
|
50 |
|
@@ -88,8 +87,7 @@ def prepare_sentences(text, lang="mya"):
|
|
88 |
|
89 |
print("Processed text", text)
|
90 |
|
91 |
-
paragraphs = [paragraph for paragraph in text.split(
|
92 |
-
"\n") if paragraph.strip()]
|
93 |
|
94 |
if lang.lower() == "vie":
|
95 |
for paragraph in paragraphs:
|
@@ -129,8 +127,7 @@ def list_dir():
|
|
129 |
|
130 |
def combine_wav(source_dir, stamp):
|
131 |
# Get a list of all WAV files in the folder
|
132 |
-
wav_files = [file for file in os.listdir(
|
133 |
-
source_dir) if file.endswith(".wav")]
|
134 |
|
135 |
# Sort the files alphabetically to ensure the correct order of combination
|
136 |
wav_files.sort()
|
@@ -173,8 +170,7 @@ def mms_tts(Input_Text, lang_name="Burmese (mya)"):
|
|
173 |
print("New user directory", user_dir)
|
174 |
|
175 |
for i, sentence in enumerate(sentences):
|
176 |
-
tts.synthesis(
|
177 |
-
sentence, wav_path=f"{user_dir}/s_{str(i).zfill(10)}.wav")
|
178 |
combined_file_path = combine_wav(user_dir, timestamp)
|
179 |
return combined_file_path
|
180 |
|
@@ -185,10 +181,11 @@ iface = gr.Interface(
|
|
185 |
title="Massively Multilingual Speech (MMS) - Text To Speech",
|
186 |
description=this_description,
|
187 |
inputs=[
|
188 |
-
gr.Textbox(lines=5, placeholder="Enter text to speech",
|
189 |
-
label="Input text"),
|
190 |
gr.Dropdown(
|
191 |
-
choices=language_names,
|
|
|
|
|
192 |
),
|
193 |
],
|
194 |
outputs="audio",
|
|
|
43 |
with open("lang_code.json") as f:
|
44 |
lang_codes = json.load(f, object_pairs_hook=OrderedDict)
|
45 |
|
46 |
+
lang_codes = {key + " (" + lang_codes[key] + ")": lang_codes[key] for key in lang_codes}
|
|
|
47 |
# Extract language names
|
48 |
language_names = list(lang_codes.keys())
|
49 |
|
|
|
87 |
|
88 |
print("Processed text", text)
|
89 |
|
90 |
+
paragraphs = [paragraph for paragraph in text.split("\n") if paragraph.strip()]
|
|
|
91 |
|
92 |
if lang.lower() == "vie":
|
93 |
for paragraph in paragraphs:
|
|
|
127 |
|
128 |
def combine_wav(source_dir, stamp):
|
129 |
# Get a list of all WAV files in the folder
|
130 |
+
wav_files = [file for file in os.listdir(source_dir) if file.endswith(".wav")]
|
|
|
131 |
|
132 |
# Sort the files alphabetically to ensure the correct order of combination
|
133 |
wav_files.sort()
|
|
|
170 |
print("New user directory", user_dir)
|
171 |
|
172 |
for i, sentence in enumerate(sentences):
|
173 |
+
tts.synthesis(sentence, wav_path=f"{user_dir}/s_{str(i).zfill(10)}.wav")
|
|
|
174 |
combined_file_path = combine_wav(user_dir, timestamp)
|
175 |
return combined_file_path
|
176 |
|
|
|
181 |
title="Massively Multilingual Speech (MMS) - Text To Speech",
|
182 |
description=this_description,
|
183 |
inputs=[
|
184 |
+
gr.Textbox(lines=5, placeholder="Enter text to speech", label="Input text"),
|
|
|
185 |
gr.Dropdown(
|
186 |
+
choices=language_names,
|
187 |
+
label="Select language 1,000+",
|
188 |
+
value="Burmese (mya)",
|
189 |
),
|
190 |
],
|
191 |
outputs="audio",
|