Spaces:
Runtime error
Runtime error
import gradio as gr | |
import whisper | |
from langcodes import * | |
def speech_to_text(tmp_filename, uploaded, model_size): | |
model = whisper.load_model(model_size) | |
source = uploaded if uploaded is not None else tmp_filename | |
result = model.transcribe(source) | |
return f'Detected language: {Language.make(language=result["language"]).display_name()}\n\n You said: {result["text"]}' | |
gr.Interface( | |
title="", | |
thumbnail="", | |
css=""" | |
footer {visibility: hidden} | |
.gr-prose p{text-align: center;} | |
.gr-button {background: black;color: white} | |
""", | |
description="", | |
fn=speech_to_text, | |
inputs=[ | |
gr.Audio(source="upload", type="filepath", label="Upload Audio"), | |
gr.Dropdown(label="Select model size",value="base",choices=["tiny", "base", "small", "medium", "large"])], | |
outputs="text").launch() | |