Uberi / speech_recognition

Speech recognition module for Python, supporting several engines and APIs, online and offline.
https://pypi.python.org/pypi/SpeechRecognition/
BSD 3-Clause "New" or "Revised" License
8.28k stars 2.39k forks source link

Google speech recognize unable to transcribe the audio which is in Indian English (en-IN) format from other regions like US. #417

Open B3DS-D01 opened 5 years ago

B3DS-D01 commented 5 years ago

Steps to reproduce

I have a audio file which is in Indian English format. When I am running the following code from from local system this code runs perfectly and transcribes successfully but if I run the same piece of code from AWS which is US region it throws the following exception.

I tried to include the language code in recognize_google() but the same issue. I had looked the 383

speech = r.recognize_google(audio, language = 'pt') File "/Library/Python/2.5/site-packages/speech_recognition/init.py", line 858, in recognize_google if not isinstance(actual_result, dict) or len(actual_result.get("alternative", [])) == 0: raise UnknownValueError() speech_recognition.UnknownValueError

`def recording(): r = sr.Recognizer() file = sr.AudioFile('qa_full_recording.wav') with file as source: r.adjust_for_ambient_noise(source, duration = 0.5) # for removing noise
audio = r.record(source, duration = 150) #remove the 'duration' argument to transcribe complete audio file

txt = r.recognize_google(audio,language="en-IN")
text = repr(txt)
print (text)
return text`

System information

My system is "Ubuntu 16.04 LTS x64" both local and aws

My Python version is 3.5 both on local and aws

My SpeechRecognition library version is 3.8.1

shafaypro commented 4 years ago

Have you verified the Language (try changing from en-IN to UK based) , Additionally, why would you try to turn on aws specific machine(EC2) microphone for this task?