| Reference | Downloads | Github

Speech Recognition

I am trying to write a speech recognition code in psychopy but I am getting the following error
File “C:\Users\hp\Desktop\psychopy_exp\”, line 11, in
File “C:\Users\hp\AppData\Roaming\Python\Python36\site-packages\”, line 845, in recognize_google
response_text =“utf-8”)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x8b in position 1: invalid start byte

The code is as follows:

r = sr.Recognizer()
with sr.Microphone(1) as source:
 print("Say Something");
 r.adjust_for_ambient_noise(source, duration=1)
 audio = r.listen(source)
 print("Audio captured!")
 print("Time Over, Thanks")
    print("Text: "+ str);
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)) 
print('Recognition Ended')```

Can you guide me? I have tried the unicode function but its not working

Hi @Aishwarya, would you please surround your code with backticks to help readability?

Thanks for the reply.
I have done the same.