Spaces:
Runtime error
Runtime error
Download app.py from faizeeb/voice_to_text: direct link, hf CLI and curl.
- Browser
- Download file 611 Bytes
-
https://huggingface.co/spaces/faizeeb/voice_to_text/resolve/main/app.py
- Command line
-
hf download hf://spaces/faizeeb/voice_to_text/app.py
-
curl -L -o app.py https://huggingface.co/spaces/faizeeb/voice_to_text/resolve/main/app.py
611 Bytes
| 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() | |