hexgrad commited on
Commit
123602a
·
verified ·
1 Parent(s): 5211620

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -197,9 +197,12 @@ def forward(tokens, voice, speed, device='cpu'):
197
  def forward_gpu(tokens, voice, speed):
198
  return forward(tokens, voice, speed, device='cuda')
199
 
 
200
  def generate(text, voice, ps=None, speed=1, reduce_noise=0.5, opening_cut=4000, closing_cut=2000, ease_in=3000, ease_out=1000, pad_before=5000, pad_after=5000, use_gpu=None):
 
 
 
201
  if voice not in VOICES:
202
- # Ensure stability for https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
203
  voice = 'af'
204
  ps = ps or phonemize(text, voice)
205
  tokens = tokenize(ps)
@@ -274,8 +277,8 @@ with gr.Blocks() as basic_tts:
274
  ease_in = gr.Slider(minimum=0, maximum=24000, value=3000, step=1000, label='🎢 Ease In', info='Ease in samples, after opening cut')
275
  with gr.Column():
276
  ease_out = gr.Slider(minimum=0, maximum=24000, value=1000, step=1000, label='🛝 Ease Out', info='Ease out samples, before closing cut')
277
- text.submit(generate, inputs=[text, voice, in_ps, 0.5, speed, opening_cut, closing_cut, ease_in, ease_out, 5000, 5000, use_gpu], outputs=[audio, out_ps])
278
- generate_btn.click(generate, inputs=[text, voice, in_ps, 0.5, speed, opening_cut, closing_cut, ease_in, ease_out, 5000, 5000, use_gpu], outputs=[audio, out_ps])
279
 
280
  @torch.no_grad()
281
  def lf_forward(token_lists, voice, speed, device='cpu'):
 
197
  def forward_gpu(tokens, voice, speed):
198
  return forward(tokens, voice, speed, device='cuda')
199
 
200
+ # Must be backwards compatible with https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
201
  def generate(text, voice, ps=None, speed=1, reduce_noise=0.5, opening_cut=4000, closing_cut=2000, ease_in=3000, ease_out=1000, pad_before=5000, pad_after=5000, use_gpu=None):
202
+ return _generate(text, voice, ps, speed, opening_cut, closing_cut, ease_in, ease_out, use_gpu)
203
+
204
+ def _generate(text, voice, ps, speed, opening_cut, closing_cut, ease_in, ease_out, use_gpu):
205
  if voice not in VOICES:
 
206
  voice = 'af'
207
  ps = ps or phonemize(text, voice)
208
  tokens = tokenize(ps)
 
277
  ease_in = gr.Slider(minimum=0, maximum=24000, value=3000, step=1000, label='🎢 Ease In', info='Ease in samples, after opening cut')
278
  with gr.Column():
279
  ease_out = gr.Slider(minimum=0, maximum=24000, value=1000, step=1000, label='🛝 Ease Out', info='Ease out samples, before closing cut')
280
+ text.submit(_generate, inputs=[text, voice, in_ps, speed, opening_cut, closing_cut, ease_in, ease_out, use_gpu], outputs=[audio, out_ps])
281
+ generate_btn.click(_generate, inputs=[text, voice, in_ps, speed, opening_cut, closing_cut, ease_in, ease_out, use_gpu], outputs=[audio, out_ps])
282
 
283
  @torch.no_grad()
284
  def lf_forward(token_lists, voice, speed, device='cpu'):