truongghieu commited on
Commit
b887071
1 Parent(s): b3128da

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import speech_recognition as sr
2
+
3
+ def recognize_speech(audio_data):
4
+ recognizer = sr.Recognizer()
5
+
6
+ try:
7
+ text = recognizer.recognize_google(audio_data)
8
+ return f"Recognized Speech: {text}"
9
+ except sr.UnknownValueError:
10
+ return "Speech Recognition could not understand audio."
11
+ except sr.RequestError as e:
12
+ return f"Could not request results from Google Speech Recognition service; {e}"
13
+
14
+ iface = gr.Interface(fn=recognize_speech, inputs="microphone", outputs="text")
15
+ iface.launch()