Spaces:
Runtime error
Runtime error
import gradio as gr | |
import os | |
import shlex | |
import uuid | |
import torch | |
cpu_param = "--cpu" if not torch.cuda.is_available() else "" | |
import gradio as gr | |
def greet(voice): | |
iface = gr.Interface(fn=greet, inputs="text", outputs="audio") | |
iface.launch() | |
def toggle(choice): | |
if choice == "mic": | |
return gr.update(visible=True, value=None), gr.update(visible=False, value=None) | |
else: | |
return gr.update(visible=False, value=None), gr.update(visible=True, value=None) | |
with gr.Blocks() as demo: | |
with gr.Row(): | |
with gr.Column(): | |
radio = gr.Radio(["mic", "file"], value="mic", | |
label="How would you like to upload your audio?") | |
mic_input = gr.Mic(label="Input", type="filepath", visible=False) | |
audio_file = gr.Audio( | |
type="filepath", label="Input", visible=True) | |
text_input = gr.Textbox(label="Text") | |
with gr.Column(): | |
audio_output = gr.Audio(label="Output") | |
gr.Examples(fn=greet,inputs=[audio_file,text_input], | |
outputs=audio_output, cache_examples=True) | |
btn = gr.Button("Generate") | |
btn.click(inference, inputs=[audio_file, | |
text_input, mic_input], outputs=audio_output) | |
radio.change(toggle, radio, [mic_input, audio_file]) | |
demo.launch(enable_queue=True) | |