Spaces:
Runtime error
Runtime error
File size: 611 Bytes
78f03ed d932eaa 2896887 2b4f489 77c4453 06df69a c966a8c 73966c8 77c4453 73966c8 b7f99a9 77c4453 06df69a 78f03ed | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import speech_recognition as sr
import gradio as gr
def listen(audio):
r = sr.Recognizer()
sample_rate, audio_data = audio
sample_width = audio_data.dtype.itemsize
# with wave.open(audio, 'rb') as audio_file:
# sample_width = audio_file.getsampwidth()
audio = sr.AudioData(audio_data, sample_rate=sample_rate,sample_width=sample_width)
try:
text = r.recognize_google(audio, language='ur')
return text
except:
return "Sorry could not recognize what you said"
gr.Interface(fn=listen,inputs="audio",outputs="text").launch()
|