Spaces:
Runtime error
Runtime error
File size: 2,494 Bytes
b9a47ba 0a1c297 b9a47ba 1fc10f3 b9a47ba 0a1c297 b9a47ba 0a1c297 b9a47ba 0a1c297 b9a47ba 0a1c297 b9a47ba |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
from gradio import (
Audio,
Blocks,
Button,
Checkbox,
Column,
Dropdown,
Row,
Slider,
Textbox,
)
from vocalizr import CHOICES, CUDA_AVAILABLE
from vocalizr.model import generate_audio_for_text
def app_block() -> Blocks:
"""Create and return the main application interface.
:return: Blocks: The complete Gradio application interface
"""
with Blocks() as app:
with Row():
with Column():
text: Textbox = Textbox(
label="Input Text",
info="Enter your text here",
)
with Row():
voice: Dropdown = Dropdown(
choices=list(CHOICES.items()),
value="af_heart",
label="Voice",
info="Quality and availability vary by language",
)
Dropdown(
choices=[("GPU π", True), ("CPU π", False)],
value=CUDA_AVAILABLE,
label="Hardware",
info="GPU is usually faster, but has a usage quota",
interactive=CUDA_AVAILABLE,
)
save_file = Checkbox(
label="Save Audio",
info="Save audio to local storage",
)
speed: Slider = Slider(
minimum=0.5,
maximum=2,
value=1,
step=0.1,
label="Speed",
)
with Column():
out_audio: Audio = Audio(
label="Output Audio",
interactive=False,
streaming=True,
autoplay=True,
)
with Row():
stream_btn: Button = Button(
value="Generate",
variant="primary",
)
stop_btn: Button = Button(
value="Stop",
variant="stop",
)
stream_event = stream_btn.click(
fn=generate_audio_for_text,
inputs=[text, voice, speed, save_file],
outputs=[out_audio],
)
stop_btn.click(
fn=None,
cancels=stream_event,
)
return app
|