TTSApp1 / app.py
dev427tools's picture
Create app.py
52a4fb9 verified
Raw History Blame Contribute Delete
894 Bytes
import gradio as gr
from transformers import pipeline
# Load the Automatic Speech Recognition pipeline from Hugging Face
asr = pipeline("automatic-speech-recognition", model="openai/whisper-large-v3")
def transcribe(audio):
if audio is None:
return "Please record or upload an audio file."
# audio is a tuple: (sample_rate, numpy array)
result = asr(audio)["text"]
return result
description = """
# Speech-to-Text Converter
Record your voice or upload an audio file and get the transcription using Hugging Face's Whisper model.
"""
demo = gr.Interface(
fn=transcribe,
inputs=gr.Audio(source="microphone", type="numpy", label="Record or Upload Audio"),
outputs=gr.Textbox(label="Transcribed Text"),
title="Speech to Text App",
description=description,
allow_flagging="never",
theme="default"
)
if __name__ == "__main__":
demo.launch()