File size: 521 Bytes
b887071
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import speech_recognition as sr

def recognize_speech(audio_data):
    recognizer = sr.Recognizer()

    try:
        text = recognizer.recognize_google(audio_data)
        return f"Recognized Speech: {text}"
    except sr.UnknownValueError:
        return "Speech Recognition could not understand audio."
    except sr.RequestError as e:
        return f"Could not request results from Google Speech Recognition service; {e}"

iface = gr.Interface(fn=recognize_speech, inputs="microphone", outputs="text")
iface.launch()