rebego's picture
Use whisper-small and remove source param
4760e30 verified
raw
history blame contribute delete
821 Bytes
import gradio as gr
import torch
from transformers import pipeline
# 1) Pipeline de Whisper-small para ES → texto ES
device = 0 if torch.cuda.is_available() else -1
asr = pipeline(
"automatic-speech-recognition",
model="openai/whisper-small", # <-- modelo pequeño para CPU
device=device,
generate_kwargs={"task": "transcribe", "language": "es"}
)
# 2) Función de transcripción
def transcribe(audio_path):
return asr(audio_path)["text"]
# 3) Interfaz Gradio
demo = gr.Interface(
fn=transcribe,
inputs=gr.Audio(type="filepath", label="Sube audio (ES)"), # sin source="upload"
outputs=gr.Textbox(label="Transcripción"),
title="Audio→Texto en Español",
description="Transcribe audio en español con Whisper-small"
)
if __name__ == "__main__":
demo.launch()