hexgrad commited on
Commit
370a852
·
verified ·
1 Parent(s): 9845560

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -211,10 +211,10 @@ def forward_gpu(tokens, voice, speed):
211
  return forward(tokens, voice, speed, device='cuda')
212
 
213
  # Must be backwards compatible with https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
214
- def generate(text, voice, ps, speed, _reduce_noise, trim, _closing_cut, _ease_in, _ease_out, _pad_before, _pad_after):
215
- return _generate(text, voice, ps, speed, trim, 'auto')
216
-
217
- def _generate(text, voice, ps, speed, trim, use_gpu):
218
  if voice not in VOICES['cpu']:
219
  voice = 'af'
220
  ps = ps or phonemize(text, voice)
@@ -284,8 +284,8 @@ with gr.Blocks() as basic_tts:
284
  trim = gr.Slider(minimum=0, maximum=24000, value=4000, step=1000, label='✂️ Trim', info='Cut from both ends')
285
  with gr.Accordion('Output Tokens', open=True):
286
  out_ps = gr.Textbox(interactive=False, show_label=False, info='Tokens used to generate the audio, up to 510 allowed. Same as input tokens if supplied, excluding unknowns.')
287
- text.submit(_generate, inputs=[text, voice, in_ps, speed, trim, use_gpu], outputs=[audio, out_ps])
288
- generate_btn.click(_generate, inputs=[text, voice, in_ps, speed, trim, use_gpu], outputs=[audio, out_ps])
289
 
290
  @torch.no_grad()
291
  def lf_forward(token_lists, voice, speed, device='cpu'):
 
211
  return forward(tokens, voice, speed, device='cuda')
212
 
213
  # Must be backwards compatible with https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
214
+ def generate(*args):
215
+ text, voice, ps, speed = args[:4]
216
+ trim = args[4] if len(args) > 4 and isinstance(args[4], int) else 4000
217
+ use_gpu = args[5] if len(args) > 5 and args[5] in ('auto', False, True) else 'auto'
218
  if voice not in VOICES['cpu']:
219
  voice = 'af'
220
  ps = ps or phonemize(text, voice)
 
284
  trim = gr.Slider(minimum=0, maximum=24000, value=4000, step=1000, label='✂️ Trim', info='Cut from both ends')
285
  with gr.Accordion('Output Tokens', open=True):
286
  out_ps = gr.Textbox(interactive=False, show_label=False, info='Tokens used to generate the audio, up to 510 allowed. Same as input tokens if supplied, excluding unknowns.')
287
+ text.submit(generate, inputs=[text, voice, in_ps, speed, trim, use_gpu], outputs=[audio, out_ps])
288
+ generate_btn.click(generate, inputs=[text, voice, in_ps, speed, trim, use_gpu], outputs=[audio, out_ps])
289
 
290
  @torch.no_grad()
291
  def lf_forward(token_lists, voice, speed, device='cpu'):