AI_Application / app.py
Antoniskaraolis's picture
Update app.py
8f1209b
raw
history blame
506 Bytes
import gradio as gr
from speech_recognition import Recognizer, AudioFile
def transcribe_audio(file):
recognizer = Recognizer()
with AudioFile(file) as source:
audio_data = recognizer.record(source)
try:
text = recognizer.recognize_google(audio_data)
return text
except Exception as e:
return f"Error: {str(e)}"
iface = gr.Interface(
fn=transcribe_audio,
inputs=gr.inputs.Audio(source="microphone", type="file"),
outputs="text"
)
iface.launch()