Spaces:
Running
Running
import os | |
os.system("pip install --upgrade httpx") | |
os.system("pip install --upgrade httpcore") | |
os.system("pip install --upgrade gradio") | |
import gradio as gr | |
import whisper | |
model = whisper.load_model("small") | |
def inference(audio): | |
audio = whisper.load_audio(audio) | |
audio = whisper.pad_or_trim(audio) | |
mel = whisper.log_mel_spectrogram(audio).to(model.device) | |
_, probs = model.detect_language(mel) | |
options = whisper.DecodingOptions(fp16=False) | |
result = whisper.decode(model, mel, options) | |
print(result.text) | |
return result.text | |
css = "footer {visibility: hidden}" | |
with gr.Blocks(css=css) as block: | |
with gr.Row(): | |
with gr.Column(): | |
audio = gr.Audio(label="Input Audio", type="filepath") | |
with gr.Column(): | |
text = gr.Textbox(show_label=False) | |
btn = gr.Button("Transcribir") | |
btn.click(inference, inputs=[audio], outputs=[text]) | |
block.launch() | |