SayaSS commited on
Commit
eaa3271
1 Parent(s): 35208e1

update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -64,14 +64,14 @@ def create_tts_fn(net_g_ms, speaker_id):
64
  return tts_fn
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
74
- return (_clean_text(clean_text, hps.data.text_cleaners), input_text) if is_symbol_input else (temp_text, temp_text)
75
 
76
  return to_symbol_fn
77
  def change_lang(language):
@@ -163,7 +163,6 @@ if __name__ == '__main__':
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")
168
  symbol_list = gr.Dataset(label="Symbol list", components=[input_text],
169
  samples=[[x] for x in hps_ms.symbols])
@@ -182,8 +181,8 @@ if __name__ == '__main__':
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],
189
  _js=f"""
@@ -221,7 +220,6 @@ if __name__ == '__main__':
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="符号输入")
226
  symbol_list = gr.Dataset(label="符号列表", components=[input_text],
227
  samples=[[x] for x in hps_ms.symbols])
@@ -240,8 +238,8 @@ if __name__ == '__main__':
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],
247
  _js=f"""
 
64
  return tts_fn
65
 
66
  def create_to_symbol_fn(hps):
67
+ def to_symbol_fn(is_symbol_input, input_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
74
+ return _clean_text(clean_text, hps.data.text_cleaners) if is_symbol_input else ''
75
 
76
  return to_symbol_fn
77
  def change_lang(language):
 
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
  symbol_input = gr.Checkbox(value=False, label="Symbol input")
167
  symbol_list = gr.Dataset(label="Symbol list", components=[input_text],
168
  samples=[[x] for x in hps_ms.symbols])
 
181
  lang.change(change_lang, inputs=[lang], outputs=[ns, nsw, ls])
182
  symbol_input.change(
183
  to_symbol_fn,
184
+ [symbol_input, input_text, lang],
185
+ [input_text]
186
  )
187
  symbol_list.click(None, [symbol_list, symbol_list_json], [input_text],
188
  _js=f"""
 
220
  lang = gr.Dropdown(label="语言", choices=["中文", "日语", "中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)"],
221
  type="index", value="中文"if language == "Chinese" else "日语")
222
  with gr.Accordion(label="高级选项", open=False):
 
223
  symbol_input = gr.Checkbox(value=False, label="符号输入")
224
  symbol_list = gr.Dataset(label="符号列表", components=[input_text],
225
  samples=[[x] for x in hps_ms.symbols])
 
238
  lang.change(change_lang, inputs=[lang], outputs=[ns, nsw, ls])
239
  symbol_input.change(
240
  to_symbol_fn,
241
+ [symbol_input, input_text, lang],
242
+ [input_text]
243
  )
244
  symbol_list.click(None, [symbol_list, symbol_list_json], [input_text],
245
  _js=f"""