Linux support: audible beeps via the beepy library now works
Linux support: opening Firefox now works
Optimized the recognizer instance to run only one time, rather than each time takeCommand() runs. See below for details.
I moved the recognizer instance to outside of the function body (towards the top of the file).
This is so that it only gets called once and doesn't keep creating a new object each time Jarvis listens. I added r.adjust_ambient_noise(source, 2) as well, which starts at the very beginning when you run python main.py, and runs only once. The recognizer will collect ambient audio for a couple of seconds. This is good in case you have a lot of ambient noise (my laptop's fan is normally obnoxious). The takeCommand function refers to this now outer-scoped recognizer instance rather than creating a new recognizer instance every time the function runs, which eliminates the need to constantly adjust for ambient noise each time Jarvis needs to listen (this was huge for me). It's like as if it just collects ambient audio once, then saves it for all future listenings, until you stop the script.
Feel free to comment out the ambient audio thing if need be.. I can't get PyJARVIS to work without it, but I can just uncomment when I'm testing things.
The following changes were made:
takeCommand()
runs. See below for details.I moved the recognizer instance to outside of the function body (towards the top of the file). This is so that it only gets called once and doesn't keep creating a new object each time Jarvis listens. I added
r.adjust_ambient_noise(source, 2)
as well, which starts at the very beginning when you runpython main.py
, and runs only once. The recognizer will collect ambient audio for a couple of seconds. This is good in case you have a lot of ambient noise (my laptop's fan is normally obnoxious). ThetakeCommand
function refers to this now outer-scoped recognizer instance rather than creating a new recognizer instance every time the function runs, which eliminates the need to constantly adjust for ambient noise each time Jarvis needs to listen (this was huge for me). It's like as if it just collects ambient audio once, then saves it for all future listenings, until you stop the script.