Spaces:
Sleeping
Sleeping
File size: 977 Bytes
30a42c9 061a46e 30a42c9 061a46e 30a42c9 061a46e 30a42c9 061a46e 30a42c9 a86dc23 30a42c9 061a46e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import gradio as gr
import speech_recognition as sr
def speech_to_text_from_file(audio_file):
recognizer = sr.Recognizer()
try:
with sr.AudioFile(audio_file) as source:
audio = recognizer.record(source)
text = recognizer.recognize_google(audio)
return text
except sr.UnknownValueError:
return "❌ Could not understand the audio."
except sr.RequestError:
return "❌ API unavailable or internet issue."
except Exception as e:
return f"❌ Error: {str(e)}"
iface = gr.Interface(
fn=speech_to_text_from_file,
inputs=gr.Audio(type="filepath", label="Upload Audio File (WAV/FLAC/AIFF)"),
outputs=gr.Textbox(label="Transcribed Text"),
title="🗣️ Speech-to-Text Converter",
description="Upload an audio file (WAV, FLAC, AIFF) to get a text transcription using Google Speech Recognition.",
allow_flagging="never"
)
if __name__ == "__main__":
iface.launch() |