Open teodorkasap opened 3 years ago
I finally have it sorted out. for people like myself, who are not an expert in this field I would like to write it down below and close this ticket myself. the method I have mentioned about should actually look like the following:
def handleText(self, audio):
try:
text = self.r.recognize_google(
audio,
# key="GOOGLE_APPLICATION_CREDENTIALS",
language=self.language
)
if text:
textBuffer.append(text)
print(text)
self.statusBar().showMessage("received transcription \
from Google API")
else:
print('something went wrong')
# print(self.r.recognize_google(audio))
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition \
service{0}".format(e))
raise(e)
I believe it is this sleeplessness taking itst toll during the pandemic. I have copied and pasted the wrong code and put it to work as if it was the right one.. I have written the code below and it does not accept the credentials file as valid Json string.
def handleText(self, audio):
try:
text = self.r.recognize_google_cloud(
audio,
credentials_json="GOOGLE_APPLICATION_CREDENTIALS",
language=self.language
)
if text:
textBuffer.append(text)
print(text)
self.statusBar().showMessage("received transcription \
from Google API")
else:
print('something went wrong')
# print(self.r.recognize_google(audio))
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition \
service{0}".format(e))
raise(e)
I have seen a similar issue which still hasn't been resolved so therefore I guess I should switch to using Google API without third-party Library
Steps to reproduce
As I mentioned all works fine, when I use
as soon as I add the environment variable like below:
and pass the environment variable as parameter like in the code below
I get the error I have pasted above
System information
(Delete all the statements that don't apply.)
My system is Ubuntu 18.04.05
My Python version is Python 3.7.1 (anaconda distribution)
My Pip version is pip 20.2.3.
My SpeechRecognition library version is 3.8.1.
My PyAudio library version is 0.2.11
My microphones are: (You can check this by running
python -c "import speech_recognition as sr;print(sr.Microphone.list_microphone_names())"
.)My working microphones are: ['HDA Intel HDMI: 0 (hw:0,3)', 'HDA Intel HDMI: 1 (hw:0,7)', 'HDA Intel HDMI: 2 (hw:0,8)', 'HDA Intel HDMI: 3 (hw:0,9)', 'HDA Intel HDMI: 4 (hw:0,10)', 'HDA Intel PCH: ALC3232 Analog (hw:1,0)', 'Logitech Mono H650e: USB Audio (hw:2,0)', 'hdmi', 'pulse', 'default']
I did not install PocketSphinx.