I am currently developing a smart assistant program (basically it is just listening to what the user says and based on that does something with the code). It was working fine up until today, when I switched to my laptop. The program does not print out any errors, but it also doesn't print out what I said. I'm using the Python Speech Recognition library version 3.8.1. Does anybody know of an alternative for this library? If yes, please try to explain how I would use it 'on the fly' (without first recording the file and then sending it to the server, more like real-time speech).
EDIT: I forgot to say it in the post, I'm using Python 3.
EDIT: Here's the code:
#!/usr/bin/env python3
import speech_recognition as sr
global x
def speech():
try:
with sr.Microphone() as source:
global x
r = sr.Recognizer()
audio = r.listen(source)
x = r.recognize_google(audio)
except sr.UnknownValueError:
print("No clue what you said, listening again... \n")
speech()
if __name__ == '__main__':
print('Listening and printing what I heard: \n')
speech()
print(x)
I found that the problem was in the laptop's microphone. The speech recognition worked fine after I plugged in my Blue Snowball. I forced the program to use the Blue Snowball by going into pavucontrol and selecting the Blue Snowball under the recording tab.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With