Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py
Browse files
app.py
CHANGED
@@ -220,12 +220,12 @@ def clamp_speed(speed):
|
|
220 |
return speed
|
221 |
|
222 |
# Must be backwards compatible with https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
|
223 |
-
def generate(text, voice='af', ps=None, speed=1, trim=
|
224 |
voice = voice if voice in VOICES['cpu'] else 'af'
|
225 |
ps = ps or phonemize(text, voice)
|
226 |
speed = clamp_speed(speed)
|
227 |
-
trim = trim if isinstance(trim, int) else
|
228 |
-
use_gpu =
|
229 |
tokens = tokenize(ps)
|
230 |
if not tokens:
|
231 |
return (None, '')
|
@@ -289,11 +289,18 @@ with gr.Blocks() as basic_tts:
|
|
289 |
autoplay = gr.Checkbox(value=True, label='Autoplay')
|
290 |
autoplay.change(toggle_autoplay, inputs=[autoplay], outputs=[audio])
|
291 |
speed = gr.Slider(minimum=0.5, maximum=2, value=1, step=0.1, label='⚡️ Speed', info='Adjust the speaking speed')
|
292 |
-
trim = gr.Slider(minimum=0, maximum=24000, value=
|
293 |
with gr.Accordion('Output Tokens', open=True):
|
294 |
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.')
|
295 |
-
|
296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
297 |
|
298 |
@torch.no_grad()
|
299 |
def lf_forward(token_lists, voice, speed, device='cpu'):
|
|
|
220 |
return speed
|
221 |
|
222 |
# Must be backwards compatible with https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
|
223 |
+
def generate(text, voice='af', ps=None, speed=1, _reduce_noise=0.5, trim=3000, _closing_cut=2000, _ease_in=3000, _ease_out=1000, _pad_before=5000, _pad_after=5000, use_gpu='auto'):
|
224 |
voice = voice if voice in VOICES['cpu'] else 'af'
|
225 |
ps = ps or phonemize(text, voice)
|
226 |
speed = clamp_speed(speed)
|
227 |
+
trim = trim if isinstance(trim, int) else 3000
|
228 |
+
use_gpu = use_gpu if use_gpu in ('auto', False, True) else 'auto'
|
229 |
tokens = tokenize(ps)
|
230 |
if not tokens:
|
231 |
return (None, '')
|
|
|
289 |
autoplay = gr.Checkbox(value=True, label='Autoplay')
|
290 |
autoplay.change(toggle_autoplay, inputs=[autoplay], outputs=[audio])
|
291 |
speed = gr.Slider(minimum=0.5, maximum=2, value=1, step=0.1, label='⚡️ Speed', info='Adjust the speaking speed')
|
292 |
+
trim = gr.Slider(minimum=0, maximum=24000, value=3000, step=1000, label='✂️ Trim', info='Cut from both ends')
|
293 |
with gr.Accordion('Output Tokens', open=True):
|
294 |
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.')
|
295 |
+
with gr.Row():
|
296 |
+
_reduce_noise = gr.Slider(value=0.5, visible=False, render=False)
|
297 |
+
_closing_cut = gr.Slider(value=2000, visible=False, render=False)
|
298 |
+
_ease_in = gr.Slider(value=3000, visible=False, render=False)
|
299 |
+
_ease_out = gr.Slider(value=1000, visible=False, render=False)
|
300 |
+
_pad_before = gr.Slider(value=5000, visible=False, render=False)
|
301 |
+
_pad_after = gr.Slider(value=5000, visible=False, render=False)
|
302 |
+
text.submit(generate, inputs=[text, voice, in_ps, speed, _reduce_noise, trim, _closing_cut, _ease_in, _ease_out, _pad_before, _pad_after, use_gpu], outputs=[audio, out_ps])
|
303 |
+
generate_btn.click(generate, inputs=[text, voice, in_ps, speed, _reduce_noise, trim, _closing_cut, _ease_in, _ease_out, _pad_before, _pad_after, use_gpu], outputs=[audio, out_ps])
|
304 |
|
305 |
@torch.no_grad()
|
306 |
def lf_forward(token_lists, voice, speed, device='cpu'):
|