Spaces:
Sleeping
Sleeping
import gradio as gr | |
from whisper import generate | |
from AinaTheme import theme | |
#import spaces | |
USE_V5 = False | |
#@spaces.GPU | |
def transcribe(inputs, model_version): | |
if inputs is None: | |
raise gr.Error("Cap fitxer d'脿udio introduit! Si us plau pengeu un fitxer "\ | |
"o enregistreu un 脿udio abans d'enviar la vostra sol路licitud") | |
use_v5 = model_version == "v0.5" | |
return generate(audio_path=inputs, use_v5=use_v5) | |
description_string = "Transcripci贸 autom脿tica de micr貌fon o de fitxers d'脿udio.\n Aquest demostrador s'ha desenvolupat per"\ | |
" comprovar els models de reconeixement de parla per a m贸bils." | |
def clear(): | |
return None, "v1.0" | |
with gr.Blocks() as demo: | |
gr.Markdown(description_string) | |
with gr.Row(): | |
with gr.Column(scale=1): | |
model_version = gr.Dropdown(label="Model Version", choices=["v1.0", "v0.5"], value="v1.0") | |
input = gr.Audio(sources=["upload", "microphone"], type="filepath", label="Audio") | |
with gr.Column(scale=1): | |
output = gr.Textbox(label="Output", lines=8) | |
with gr.Row(variant="panel"): | |
clear_btn = gr.Button("Clear") | |
submit_btn = gr.Button("Submit", variant="primary") | |
submit_btn.click(fn=transcribe, inputs=[input, model_version], outputs=[output]) | |
clear_btn.click(fn=clear, inputs=[], outputs=[input, model_version], queue=False) | |
if __name__ == "__main__": | |
demo.launch() | |