Khan-6264's picture
Create app.py
d3431f2 verified
raw
history blame contribute delete
653 Bytes
import gradio as gr
import torch
from transformers import pipeline
device = "cuda" if torch.cuda.is_available() else "cpu"
stt = pipeline(
"automatic-speech-recognition",
model="openai/whisper-small",
device=0 if device == "cuda" else -1
)
def speech_to_text(audio):
result = stt(audio)
return result["text"]
app = gr.Interface(
fn=speech_to_text,
inputs=gr.Audio(
sources=["microphone"],
type="filepath",
label="Speak"
),
outputs=gr.Textbox(label="Transcribed Text"),
title="Multilingual Speech to Text AI",
description="Supports English, Urdu, and 90+ languages"
)
app.launch()