yukiakai commited on
Commit
b5a16fb
·
verified ·
1 Parent(s): 95805c5

chore: update Gradio version to "5.6"

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -12,6 +12,7 @@ from text import text_to_sequence, _clean_text
12
  from torch import no_grad, LongTensor
13
  import gradio.processing_utils as gr_processing_utils
14
  import logging
 
15
  logging.getLogger('numba').setLevel(logging.WARNING)
16
  limitation = os.getenv("SYSTEM") == "spaces" # limit text and audio length in huggingface spaces
17
 
@@ -23,7 +24,7 @@ def audio_postprocess(self, y):
23
  data = audio_postprocess_ori(self, y)
24
  if data is None:
25
  return None
26
- return gr_processing_utils.encode_url_or_file_to_base64(data["name"])
27
 
28
 
29
  gr.Audio.postprocess = audio_postprocess
@@ -189,7 +190,7 @@ if __name__ == '__main__':
189
  o2 = gr.Audio(label="Output Audio", elem_id=f"tts-audio-en-{name_en.replace(' ','')}")
190
  download = gr.Button("Download Audio")
191
  btn.click(tts_fn, inputs=[input_text, lang, ns, nsw, ls, symbol_input], outputs=[o1, o2], api_name=f"tts-{name_en}")
192
- download.click(None, [], [], _js=download_audio_js.format(audio_id=f"en-{name_en.replace(' ', '')}"))
193
  lang.change(change_lang, inputs=[lang], outputs=[ns, nsw, ls])
194
  symbol_input.change(
195
  to_symbol_fn,
@@ -197,7 +198,7 @@ if __name__ == '__main__':
197
  [input_text]
198
  )
199
  symbol_list.click(None, [symbol_list, symbol_list_json], [input_text],
200
- _js=f"""
201
  (i,symbols) => {{
202
  let root = document.querySelector("body > gradio-app");
203
  if (root.shadowRoot != null)
@@ -248,7 +249,7 @@ if __name__ == '__main__':
248
  o2 = gr.Audio(label="输出音频", elem_id=f"tts-audio-zh-{name_zh}")
249
  download = gr.Button("下载音频")
250
  btn.click(tts_fn, inputs=[input_text, lang, ns, nsw, ls, symbol_input], outputs=[o1, o2])
251
- download.click(None, [], [], _js=download_audio_js.format(audio_id=f"zh-{name_zh}"))
252
  lang.change(change_lang, inputs=[lang], outputs=[ns, nsw, ls])
253
  symbol_input.change(
254
  to_symbol_fn,
@@ -256,7 +257,7 @@ if __name__ == '__main__':
256
  [input_text]
257
  )
258
  symbol_list.click(None, [symbol_list, symbol_list_json], [input_text],
259
- _js=f"""
260
  (i,symbols) => {{
261
  let root = document.querySelector("body > gradio-app");
262
  if (root.shadowRoot != null)
@@ -287,4 +288,4 @@ if __name__ == '__main__':
287
  </center>
288
  '''
289
  )
290
- app.queue(concurrency_count=1, api_open=args.api).launch(share=args.share)
 
12
  from torch import no_grad, LongTensor
13
  import gradio.processing_utils as gr_processing_utils
14
  import logging
15
+ from gradio_client import utils as client_utils
16
  logging.getLogger('numba').setLevel(logging.WARNING)
17
  limitation = os.getenv("SYSTEM") == "spaces" # limit text and audio length in huggingface spaces
18
 
 
24
  data = audio_postprocess_ori(self, y)
25
  if data is None:
26
  return None
27
+ return client_utils.encode_url_or_file_to_base64(data.path)
28
 
29
 
30
  gr.Audio.postprocess = audio_postprocess
 
190
  o2 = gr.Audio(label="Output Audio", elem_id=f"tts-audio-en-{name_en.replace(' ','')}")
191
  download = gr.Button("Download Audio")
192
  btn.click(tts_fn, inputs=[input_text, lang, ns, nsw, ls, symbol_input], outputs=[o1, o2], api_name=f"tts-{name_en}")
193
+ download.click(None, [], [], js=download_audio_js.format(audio_id=f"en-{name_en.replace(' ', '')}"))
194
  lang.change(change_lang, inputs=[lang], outputs=[ns, nsw, ls])
195
  symbol_input.change(
196
  to_symbol_fn,
 
198
  [input_text]
199
  )
200
  symbol_list.click(None, [symbol_list, symbol_list_json], [input_text],
201
+ js=f"""
202
  (i,symbols) => {{
203
  let root = document.querySelector("body > gradio-app");
204
  if (root.shadowRoot != null)
 
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,
 
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)
 
288
  </center>
289
  '''
290
  )
291
+ app.queue(default_concurrency_limit=1, api_open=args.api).launch(share=args.share)