Spaces:
Runtime error
Runtime error
SayaSS
commited on
Commit
•
5b8ad64
1
Parent(s):
c58b170
update app.py
Browse files- app.py +8 -10
- text/cleaners.py +1 -1
app.py
CHANGED
@@ -65,9 +65,9 @@ def create_tts_fn(net_g_ms, speaker_id):
|
|
65 |
|
66 |
def create_to_symbol_fn(hps):
|
67 |
def to_symbol_fn(is_symbol_input, input_text, temp_text, temp_lang):
|
68 |
-
if temp_lang ==
|
69 |
clean_text = f'[ZH]{input_text}[ZH]'
|
70 |
-
elif temp_lang ==
|
71 |
clean_text = f'[JA]{input_text}[JA]'
|
72 |
else:
|
73 |
clean_text = input_text
|
@@ -76,11 +76,11 @@ def create_to_symbol_fn(hps):
|
|
76 |
return to_symbol_fn
|
77 |
def change_lang(language):
|
78 |
if language == 0:
|
79 |
-
return 0.6, 0.668, 1.2
|
80 |
elif language == 1:
|
81 |
-
return 0.6, 0.668, 1
|
82 |
else:
|
83 |
-
return 0.6, 0.668, 1
|
84 |
|
85 |
download_audio_js = """
|
86 |
() =>{{
|
@@ -162,7 +162,6 @@ if __name__ == '__main__':
|
|
162 |
input_text = gr.Textbox(label="Text (100 words limitation)" if limitation else "Text", lines=5, value=example, elem_id=f"input-text-en-{name_en.replace(' ','')}")
|
163 |
lang = gr.Dropdown(label="Language", choices=["Chinese", "Japanese", "Mix(wrap the Chinese text with [ZH][ZH], wrap the Japanese text with [JA][JA])"],
|
164 |
type="index", value=language)
|
165 |
-
temp_lang = gr.Variable(value=language)
|
166 |
with gr.Accordion(label="Advanced Options", open=False):
|
167 |
temp_text_var = gr.Variable()
|
168 |
symbol_input = gr.Checkbox(value=False, label="Symbol input")
|
@@ -180,10 +179,10 @@ if __name__ == '__main__':
|
|
180 |
download = gr.Button("Download Audio")
|
181 |
btn.click(tts_fn, inputs=[input_text, lang, ns, nsw, ls, symbol_input], outputs=[o1, o2], api_name=f"tts-{name_en}")
|
182 |
download.click(None, [], [], _js=download_audio_js.format(audio_id=f"en-{name_en.replace(' ', '')}"))
|
183 |
-
lang.change(change_lang, inputs=[lang], outputs=[ns, nsw, ls
|
184 |
symbol_input.change(
|
185 |
to_symbol_fn,
|
186 |
-
[symbol_input, input_text, temp_text_var,
|
187 |
[input_text, temp_text_var]
|
188 |
)
|
189 |
symbol_list.click(None, [symbol_list, symbol_list_json], [input_text],
|
@@ -221,7 +220,6 @@ if __name__ == '__main__':
|
|
221 |
input_text = gr.Textbox(label="文本 (100字上限)" if limitation else "文本", lines=5, value=example, elem_id=f"input-text-zh-{name_zh}")
|
222 |
lang = gr.Dropdown(label="语言", choices=["中文", "日语", "中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)"],
|
223 |
type="index", value="中文"if language == "Chinese" else "日语")
|
224 |
-
temp_lang = gr.Variable(value=language)
|
225 |
with gr.Accordion(label="高级选项", open=False):
|
226 |
temp_text_var = gr.Variable()
|
227 |
symbol_input = gr.Checkbox(value=False, label="符号输入")
|
@@ -242,7 +240,7 @@ if __name__ == '__main__':
|
|
242 |
lang.change(change_lang, inputs=[lang], outputs=[ns, nsw, ls])
|
243 |
symbol_input.change(
|
244 |
to_symbol_fn,
|
245 |
-
[symbol_input, input_text, temp_text_var,
|
246 |
[input_text, temp_text_var]
|
247 |
)
|
248 |
symbol_list.click(None, [symbol_list, symbol_list_json], [input_text],
|
|
|
65 |
|
66 |
def create_to_symbol_fn(hps):
|
67 |
def to_symbol_fn(is_symbol_input, input_text, temp_text, temp_lang):
|
68 |
+
if temp_lang == 0:
|
69 |
clean_text = f'[ZH]{input_text}[ZH]'
|
70 |
+
elif temp_lang == 1:
|
71 |
clean_text = f'[JA]{input_text}[JA]'
|
72 |
else:
|
73 |
clean_text = input_text
|
|
|
76 |
return to_symbol_fn
|
77 |
def change_lang(language):
|
78 |
if language == 0:
|
79 |
+
return 0.6, 0.668, 1.2
|
80 |
elif language == 1:
|
81 |
+
return 0.6, 0.668, 1
|
82 |
else:
|
83 |
+
return 0.6, 0.668, 1
|
84 |
|
85 |
download_audio_js = """
|
86 |
() =>{{
|
|
|
162 |
input_text = gr.Textbox(label="Text (100 words limitation)" if limitation else "Text", lines=5, value=example, elem_id=f"input-text-en-{name_en.replace(' ','')}")
|
163 |
lang = gr.Dropdown(label="Language", choices=["Chinese", "Japanese", "Mix(wrap the Chinese text with [ZH][ZH], wrap the Japanese text with [JA][JA])"],
|
164 |
type="index", value=language)
|
|
|
165 |
with gr.Accordion(label="Advanced Options", open=False):
|
166 |
temp_text_var = gr.Variable()
|
167 |
symbol_input = gr.Checkbox(value=False, label="Symbol input")
|
|
|
179 |
download = gr.Button("Download Audio")
|
180 |
btn.click(tts_fn, inputs=[input_text, lang, ns, nsw, ls, symbol_input], outputs=[o1, o2], api_name=f"tts-{name_en}")
|
181 |
download.click(None, [], [], _js=download_audio_js.format(audio_id=f"en-{name_en.replace(' ', '')}"))
|
182 |
+
lang.change(change_lang, inputs=[lang], outputs=[ns, nsw, ls])
|
183 |
symbol_input.change(
|
184 |
to_symbol_fn,
|
185 |
+
[symbol_input, input_text, temp_text_var, lang],
|
186 |
[input_text, temp_text_var]
|
187 |
)
|
188 |
symbol_list.click(None, [symbol_list, symbol_list_json], [input_text],
|
|
|
220 |
input_text = gr.Textbox(label="文本 (100字上限)" if limitation else "文本", lines=5, value=example, elem_id=f"input-text-zh-{name_zh}")
|
221 |
lang = gr.Dropdown(label="语言", choices=["中文", "日语", "中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)"],
|
222 |
type="index", value="中文"if language == "Chinese" else "日语")
|
|
|
223 |
with gr.Accordion(label="高级选项", open=False):
|
224 |
temp_text_var = gr.Variable()
|
225 |
symbol_input = gr.Checkbox(value=False, label="符号输入")
|
|
|
240 |
lang.change(change_lang, inputs=[lang], outputs=[ns, nsw, ls])
|
241 |
symbol_input.change(
|
242 |
to_symbol_fn,
|
243 |
+
[symbol_input, input_text, temp_text_var, lang],
|
244 |
[input_text, temp_text_var]
|
245 |
)
|
246 |
symbol_list.click(None, [symbol_list, symbol_list_json], [input_text],
|
text/cleaners.py
CHANGED
@@ -470,6 +470,6 @@ def zh_ja_mixture_cleaners(text):
|
|
470 |
cleaned_text=japanese_to_romaji_with_accent(japanese_text[4:-4]).replace('ts','ʦ').replace('u','ɯ').replace('...','…')
|
471 |
text = text.replace(japanese_text,cleaned_text+' ',1)
|
472 |
text=text[:-1]
|
473 |
-
if re.match('[A-Za-zɯɹəɥ→↓↑]',text[-1]):
|
474 |
text += '.'
|
475 |
return text
|
|
|
470 |
cleaned_text=japanese_to_romaji_with_accent(japanese_text[4:-4]).replace('ts','ʦ').replace('u','ɯ').replace('...','…')
|
471 |
text = text.replace(japanese_text,cleaned_text+' ',1)
|
472 |
text=text[:-1]
|
473 |
+
if len(text) and re.match('[A-Za-zɯɹəɥ→↓↑]',text[-1]):
|
474 |
text += '.'
|
475 |
return text
|