Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py
Browse files
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(
|
215 |
-
|
216 |
-
|
217 |
-
|
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(
|
288 |
-
generate_btn.click(
|
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'):
|