Speech_to_Image / app.py
DHEIVER's picture
Update app.py
032afb0 verified
raw
history blame
683 Bytes
import gradio as gr
from transformers import pipeline
# Load the automatic speech recognition pipeline
asr_pipeline = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-large-960h")
def transcribe_audio(audio):
# Transcribe the audio input
transcription = asr_pipeline(audio)[0]["transcription"]
return transcription
# Define Gradio interface
audio_input = gr.inputs.Audio(source="microphone", type="auto", label="Record Audio")
text_output = gr.outputs.Textbox(label="Transcription")
# Create the interface and launch it
interface = gr.Interface(fn=transcribe_audio, inputs=audio_input, outputs=text_output, title="Speech to Text")
interface.launch()