Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py
Browse files
app.py
CHANGED
@@ -233,7 +233,7 @@ def clamp_speed(speed):
|
|
233 |
return speed
|
234 |
|
235 |
# Must be backwards compatible with https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
|
236 |
-
def generate(text, voice='af', ps=None, speed=1, trim=3000, use_gpu='auto',
|
237 |
voices = resolve_voices(voice, warn=ps)
|
238 |
ps = ps or phonemize(text, voice)
|
239 |
speed = clamp_speed(speed)
|
@@ -246,7 +246,7 @@ def generate(text, voice='af', ps=None, speed=1, trim=3000, use_gpu='auto', sh=N
|
|
246 |
tokens = tokens[:510]
|
247 |
ps = ''.join(next(k for k, v in VOCAB.items() if i == v) for i in tokens)
|
248 |
use_gpu = len(ps) > 99 if use_gpu == 'auto' else use_gpu
|
249 |
-
print('🔥', datetime.now(), text, voices, ps, use_gpu,
|
250 |
try:
|
251 |
if use_gpu:
|
252 |
out = forward_gpu(tokens, voices, speed)
|
@@ -321,10 +321,10 @@ with gr.Blocks() as basic_tts:
|
|
321 |
btn = gr.Button(list(CHOICES.values())[i*4+j], variant='primary' if i*4+j < 10 else 'secondary')
|
322 |
btn.click(lambda v, b: f'{v}+{b}' if v.startswith(b[:2]) else b, inputs=[voice, btn], outputs=[voice])
|
323 |
voice.change(lambda v, b: gr.Button(b, variant='primary' if v.startswith(b[:2]) else 'secondary'), inputs=[voice, btn], outputs=[btn])
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
basic_tts.load(lambda r: r.session_hash, None,
|
328 |
|
329 |
@torch.no_grad()
|
330 |
def lf_forward(token_lists, voices, speed, device='cpu'):
|
|
|
233 |
return speed
|
234 |
|
235 |
# Must be backwards compatible with https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
|
236 |
+
def generate(text, voice='af', ps=None, speed=1, trim=3000, use_gpu='auto', sk=None):
|
237 |
voices = resolve_voices(voice, warn=ps)
|
238 |
ps = ps or phonemize(text, voice)
|
239 |
speed = clamp_speed(speed)
|
|
|
246 |
tokens = tokens[:510]
|
247 |
ps = ''.join(next(k for k, v in VOCAB.items() if i == v) for i in tokens)
|
248 |
use_gpu = len(ps) > 99 if use_gpu == 'auto' else use_gpu
|
249 |
+
print('🔥', datetime.now(), text, voices, ps, use_gpu, sk)
|
250 |
try:
|
251 |
if use_gpu:
|
252 |
out = forward_gpu(tokens, voices, speed)
|
|
|
321 |
btn = gr.Button(list(CHOICES.values())[i*4+j], variant='primary' if i*4+j < 10 else 'secondary')
|
322 |
btn.click(lambda v, b: f'{v}+{b}' if v.startswith(b[:2]) else b, inputs=[voice, btn], outputs=[voice])
|
323 |
voice.change(lambda v, b: gr.Button(b, variant='primary' if v.startswith(b[:2]) else 'secondary'), inputs=[voice, btn], outputs=[btn])
|
324 |
+
sk = gr.State()
|
325 |
+
text.submit(generate, inputs=[text, voice, in_ps, speed, trim, use_gpu, sk], outputs=[audio, out_ps])
|
326 |
+
generate_btn.click(generate, inputs=[text, voice, in_ps, speed, trim, use_gpu, sk], outputs=[audio, out_ps])
|
327 |
+
basic_tts.load(lambda r: r.session_hash, None, sk)
|
328 |
|
329 |
@torch.no_grad()
|
330 |
def lf_forward(token_lists, voices, speed, device='cpu'):
|