Speech / app.py
Sayiqa's picture
Update app.py
55a76d4 verified
raw
history blame contribute delete
744 Bytes
import gradio as gr
import time
from transformers import pipeline
p = pipeline("automatic-speech-recognition")
# Define the transcription function
def transcribe(audio_path, state):
try:
# Transcribe the audio file
result = speech_to_text_pipeline(audio_path)
transcription = result['text']
except Exception as e:
transcription = f"An error occurred: {str(e)}"
return transcription, state
# Create the Gradio interface
gr.Interface(
fn=transcribe,
inputs=[
gr.Audio(type="filepath"), # Removed 'live' from here
"state"
],
outputs=[
"textbox", # Display the transcribed text
"state"
],
live=True # Specify 'live' interaction here
).launch()