yukiakai commited on
Commit
4320db1
·
verified ·
1 Parent(s): 18bd94b

refactor: remove chinese

Browse files
Files changed (1) hide show
  1. app.py +1 -60
app.py CHANGED
@@ -136,7 +136,6 @@ if __name__ == '__main__':
136
  cover = f"pretrained_models/{i}/{info['cover']}"
137
  example = info['example']
138
  language = info['language']
139
- image_cover = client_utils.encode_url_or_file_to_base64(cover)
140
  net_g_ms = SynthesizerTrn(
141
  len(hps_ms.symbols),
142
  hps_ms.data.filter_length // 2 + 1,
@@ -164,6 +163,7 @@ if __name__ == '__main__':
164
  continue
165
  with gr.TabItem(name_en):
166
  with gr.Row():
 
167
  gr.Markdown(
168
  '<div align="center">'
169
  f'<a><strong>{title}</strong></a>'
@@ -217,65 +217,6 @@ if __name__ == '__main__':
217
  window.scrollTo(x, y);
218
  return text_input.value;
219
  }}""")
220
- with gr.TabItem("中文"):
221
- for (sid, name_en, name_zh, title, cover, example, language, net_g_ms, tts_fn, to_symbol_fn) in models:
222
- if title.split("-")[0] != category:
223
- continue
224
- with gr.TabItem(name_zh):
225
- with gr.Row():
226
- gr.Markdown(
227
- '<div align="center">'
228
- f'<a><strong>{title}</strong></a>'
229
- f'<img style="width:auto;height:300px;" src="{image_cover}">' if cover else ""
230
- '</div>'
231
- )
232
- with gr.Row():
233
- with gr.Column():
234
- input_text = gr.Textbox(label="文本 (100字上限)" if limitation else "文本", lines=5, value=example, elem_id=f"input-text-zh-{name_zh}")
235
- lang = gr.Dropdown(label="语言", choices=["中文", "日语", "中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)"],
236
- type="index", value="中文"if language == "Chinese" else "日语")
237
- with gr.Accordion(label="高级选项", open=False):
238
- symbol_input = gr.Checkbox(value=False, label="符号输入")
239
- symbol_list = gr.Dataset(label="符号列表", components=[input_text],
240
- samples=[[x] for x in hps_ms.symbols])
241
- symbol_list_json = gr.Json(value=hps_ms.symbols, visible=False)
242
- btn = gr.Button(value="生成", variant="primary")
243
- with gr.Row():
244
- ns = gr.Slider(label="控制感情变化程度", minimum=0.1, maximum=1.0, step=0.1, value=0.6, interactive=True)
245
- nsw = gr.Slider(label="控制音素发音长度", minimum=0.1, maximum=1.0, step=0.1, value=0.668, interactive=True)
246
- ls = gr.Slider(label="控制整体语速", minimum=0.1, maximum=2.0, step=0.1, value=1.2 if language=="Chinese" else 1, interactive=True)
247
- with gr.Column():
248
- o1 = gr.Textbox(label="输出信息")
249
- o2 = gr.Audio(label="输出音频", elem_id=f"tts-audio-zh-{name_zh}")
250
- download = gr.Button("下载音频")
251
- btn.click(tts_fn, inputs=[input_text, lang, ns, nsw, ls, symbol_input], outputs=[o1, o2])
252
- download.click(None, [], [], js=download_audio_js.format(audio_id=f"zh-{name_zh}"))
253
- lang.change(change_lang, inputs=[lang], outputs=[ns, nsw, ls])
254
- symbol_input.change(
255
- to_symbol_fn,
256
- [symbol_input, input_text, lang],
257
- [input_text]
258
- )
259
- symbol_list.click(None, [symbol_list, symbol_list_json], [input_text],
260
- js=f"""
261
- (i,symbols) => {{
262
- let root = document.querySelector("body > gradio-app");
263
- if (root.shadowRoot != null)
264
- root = root.shadowRoot;
265
- let text_input = root.querySelector("#input-text-zh-{name_zh}").querySelector("textarea");
266
- let startPos = text_input.selectionStart;
267
- let endPos = text_input.selectionEnd;
268
- let oldTxt = text_input.value;
269
- let result = oldTxt.substring(0, startPos) + symbols[i] + oldTxt.substring(endPos);
270
- text_input.value = result;
271
- let x = window.scrollX, y = window.scrollY;
272
- text_input.focus();
273
- text_input.selectionStart = startPos + symbols[i].length;
274
- text_input.selectionEnd = startPos + symbols[i].length;
275
- text_input.blur();
276
- window.scrollTo(x, y);
277
- return text_input.value;
278
- }}""")
279
  for category, link in others.items():
280
  with gr.TabItem(category):
281
  gr.Markdown(
 
136
  cover = f"pretrained_models/{i}/{info['cover']}"
137
  example = info['example']
138
  language = info['language']
 
139
  net_g_ms = SynthesizerTrn(
140
  len(hps_ms.symbols),
141
  hps_ms.data.filter_length // 2 + 1,
 
163
  continue
164
  with gr.TabItem(name_en):
165
  with gr.Row():
166
+ image_cover = client_utils.encode_url_or_file_to_base64(cover)
167
  gr.Markdown(
168
  '<div align="center">'
169
  f'<a><strong>{title}</strong></a>'
 
217
  window.scrollTo(x, y);
218
  return text_input.value;
219
  }}""")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  for category, link in others.items():
221
  with gr.TabItem(category):
222
  gr.Markdown(