File size: 821 Bytes
e7977e9
 
 
 
4760e30
e7977e9
 
 
4760e30
e7977e9
4760e30
e7977e9
 
 
 
4760e30
e7977e9
 
 
 
4760e30
e7977e9
 
4760e30
e7977e9
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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()