asr-inference / app.py
ankush13r's picture
adding new version of whisper
b7fa1b5
raw
history blame
1.58 kB
import gradio as gr
from whisper import generate
from AinaTheme import theme
MODEL_NAME = "/whisper-large-v3"
USE_V4 = False
def transcribe(inputs, use_v4):
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")
return generate(audio_path=inputs, use_v4=use_v4)
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. Per ara utilitza el checkpoint "\
f"[{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) i la llibreria de 馃 Transformers per a la transcripci贸."
def clear():
return (
None,
USE_V4
)
with gr.Blocks(theme=theme) as demo:
gr.Markdown(description_string)
with gr.Row():
with gr.Column(scale=1):
use_v4 = gr.Checkbox(label="Use v4", value=USE_V4)
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, use_v4], outputs=[output])
clear_btn.click(fn=clear,inputs=[], outputs=[input, use_v4], queue=False,)
if __name__ == "__main__":
demo.launch()