Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py
Browse files
app.py
CHANGED
@@ -416,19 +416,10 @@ def change_language(value):
|
|
416 |
choices = list(PREVIEW_CHOICES[value].items())
|
417 |
return gr.Dropdown(choices, value=choices[0][1], label='Voice', info='⭐ voices are stable, 🧪 are unstable')
|
418 |
|
419 |
-
USE_GPU_CHOICES = [('Auto 🔀', 'auto'), ('CPU 💬', False), ('ZeroGPU 📄', True)]
|
420 |
-
USE_GPU_INFOS = {
|
421 |
-
'auto': 'Use CPU or GPU, whichever is faster',
|
422 |
-
False: 'CPU is ~faster <100 tokens',
|
423 |
-
True: 'ZeroGPU is ~faster >100 tokens',
|
424 |
-
}
|
425 |
-
def change_use_gpu(value):
|
426 |
-
return gr.Dropdown(USE_GPU_CHOICES, value=value, label='Hardware', info=USE_GPU_INFOS[value], interactive=CUDA_AVAILABLE)
|
427 |
-
|
428 |
from gradio_client import Client
|
429 |
client = Client('hexgrad/kokoro-src', hf_token=os.environ['SRC'])
|
430 |
-
def preview(text, voice, speed, trim,
|
431 |
-
return client.predict(text=text, voice=voice, speed=speed, trim=trim, use_gpu=
|
432 |
|
433 |
with gr.Blocks() as preview_tts:
|
434 |
with gr.Row():
|
@@ -436,17 +427,8 @@ with gr.Blocks() as preview_tts:
|
|
436 |
with gr.Row():
|
437 |
with gr.Column():
|
438 |
text = gr.Textbox(label='Input Text', info='Generate speech for one segment of text, up to ~500 characters')
|
439 |
-
|
440 |
-
|
441 |
-
lang.change(fn=change_language, inputs=[lang], outputs=[voice])
|
442 |
-
use_gpu = gr.Dropdown(
|
443 |
-
USE_GPU_CHOICES,
|
444 |
-
value='auto' if CUDA_AVAILABLE else False,
|
445 |
-
label='Hardware',
|
446 |
-
info=USE_GPU_INFOS['auto' if CUDA_AVAILABLE else False],
|
447 |
-
interactive=CUDA_AVAILABLE
|
448 |
-
)
|
449 |
-
use_gpu.change(fn=change_use_gpu, inputs=[use_gpu], outputs=[use_gpu])
|
450 |
with gr.Row():
|
451 |
random_btn = gr.Button('Random Text', variant='secondary')
|
452 |
generate_btn = gr.Button('Generate', variant='primary')
|
@@ -461,8 +443,17 @@ with gr.Blocks() as preview_tts:
|
|
461 |
with gr.Row():
|
462 |
sk = gr.Textbox(visible=False)
|
463 |
text.change(lambda: os.environ['SK'], outputs=[sk])
|
464 |
-
text.submit(preview, inputs=[text, voice, speed, trim,
|
465 |
-
generate_btn.click(preview, inputs=[text, voice, speed, trim,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
466 |
|
467 |
with gr.Blocks() as basic_tts:
|
468 |
with gr.Row():
|
|
|
416 |
choices = list(PREVIEW_CHOICES[value].items())
|
417 |
return gr.Dropdown(choices, value=choices[0][1], label='Voice', info='⭐ voices are stable, 🧪 are unstable')
|
418 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
from gradio_client import Client
|
420 |
client = Client('hexgrad/kokoro-src', hf_token=os.environ['SRC'])
|
421 |
+
def preview(text, voice, speed, trim, sk):
|
422 |
+
return client.predict(text=text, voice=voice, speed=speed, trim=trim, use_gpu=True, sk=sk, api_name='/generate')[0]
|
423 |
|
424 |
with gr.Blocks() as preview_tts:
|
425 |
with gr.Row():
|
|
|
427 |
with gr.Row():
|
428 |
with gr.Column():
|
429 |
text = gr.Textbox(label='Input Text', info='Generate speech for one segment of text, up to ~500 characters')
|
430 |
+
voice = gr.Dropdown(list(PREVIEW_CHOICES['a'].items()), value='af', label='Voice', info='⭐ voices are stable, 🧪 are unstable')
|
431 |
+
lang.change(fn=change_language, inputs=[lang], outputs=[voice])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
432 |
with gr.Row():
|
433 |
random_btn = gr.Button('Random Text', variant='secondary')
|
434 |
generate_btn = gr.Button('Generate', variant='primary')
|
|
|
443 |
with gr.Row():
|
444 |
sk = gr.Textbox(visible=False)
|
445 |
text.change(lambda: os.environ['SK'], outputs=[sk])
|
446 |
+
text.submit(preview, inputs=[text, voice, speed, trim, sk], outputs=[audio])
|
447 |
+
generate_btn.click(preview, inputs=[text, voice, speed, trim, sk], outputs=[audio])
|
448 |
+
|
449 |
+
USE_GPU_CHOICES = [('Auto 🔀', 'auto'), ('CPU 💬', False), ('ZeroGPU 📄', True)]
|
450 |
+
USE_GPU_INFOS = {
|
451 |
+
'auto': 'Use CPU or GPU, whichever is faster',
|
452 |
+
False: 'CPU is ~faster <100 tokens',
|
453 |
+
True: 'ZeroGPU is ~faster >100 tokens',
|
454 |
+
}
|
455 |
+
def change_use_gpu(value):
|
456 |
+
return gr.Dropdown(USE_GPU_CHOICES, value=value, label='Hardware', info=USE_GPU_INFOS[value], interactive=CUDA_AVAILABLE)
|
457 |
|
458 |
with gr.Blocks() as basic_tts:
|
459 |
with gr.Row():
|