New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Snowboy hotword detection #232

Merged
merged 7 commits into from Oct 8, 2017

Conversation

Projects
None yet
4 participants
@beeedy
Contributor

beeedy commented May 11, 2017

I was unhappy with sphinx's accuracy when attempting to use it for hotword detection to help reduce the number of calls being made to (in my case) Google's cloud speech recognition service and thought Snowboy would be a great addition to this library. It is free for hobby use and runs entirely offline and so far results have been day and night. Link to Snowboy site: https://snowboy.kitt.ai/

This implementation was done such that you still use the same listen() call to get audio from the mic however you have the ability to specify that you would prefer it wait until a hotword is heard before it actually begins to record audio. When specifying you would like listen() to wait for a hotword you have to currently pass in the location of where the Snowboy source files are located on your computer. Snowboy is free for hobby use but is not free for commercial use. For this reasons I thought it would be safer to not include the source with the speech_recognition library but rather require the user to acquire it themselves.

Disclaimer: I do not work for and am not affiliated with Snowboy in any way, just found their product to be pretty slick

assert os.path.isfile(snowboy_location + "/snowboydetect.py"), "Can not find snowboydetect.py. Make sure snowboy_location is pointed at the root directory"
for f in hot_words: assert os.path.isfile(f), "Unable to locate file with given path: {}".format(f)
sys.path.append(snowboy_location)

This comment has been minimized.

@phooji

phooji Jun 28, 2017

This looks like you'll gradually be increasing the length of the path for repeated calls to __wait_for_hotword.

@phooji

phooji Jun 28, 2017

This looks like you'll gradually be increasing the length of the path for repeated calls to __wait_for_hotword.

This comment has been minimized.

@phooji

phooji Jun 28, 2017

In general, it might be nice to move some of the initialization stuff for snowboy into a separate one-time step. You're repeatedly doing work (checking path existence; appending to the sys path) that, hopefully, only needs to be done once.

@phooji

phooji Jun 28, 2017

In general, it might be nice to move some of the initialization stuff for snowboy into a separate one-time step. You're repeatedly doing work (checking path existence; appending to the sys path) that, hopefully, only needs to be done once.

# if ans is greater than 0, we found a wake word! return audio
if ans > 0:
return bytes(mic_buffer), elapsed_time

This comment has been minimized.

@phooji

phooji Jun 28, 2017

While testing this, I noticed that the STT service kept picking up the tail end of my wake word in
addition to the phrase that followed. Is that intentional? I was able to get a clean separation
(STT service only gets the phrase following the wakeword) by adding some time to elapsed_time here.

@phooji

phooji Jun 28, 2017

While testing this, I noticed that the STT service kept picking up the tail end of my wake word in
addition to the phrase that followed. Is that intentional? I was able to get a clean separation
(STT service only gets the phrase following the wakeword) by adding some time to elapsed_time here.

@wibimaster

This comment has been minimized.

Show comment
Hide comment
@wibimaster

wibimaster Oct 7, 2017

Have to test it, but a big +1 if this PR avoids the waiting time before closing the detector and starting the sr listener :)

@phooji, the time to add depends on the hot words used, right?

wibimaster commented Oct 7, 2017

Have to test it, but a big +1 if this PR avoids the waiting time before closing the detector and starting the sr listener :)

@phooji, the time to add depends on the hot words used, right?

@Uberi

This comment has been minimized.

Show comment
Hide comment
@Uberi

Uberi Oct 8, 2017

Owner

Hey @beeedy, my apologies for missing this PR. Seems to work great, thanks! My free time is rather limited at the moment, but I'll try to get this into a release within the next month.

Owner

Uberi commented Oct 8, 2017

Hey @beeedy, my apologies for missing this PR. Seems to work great, thanks! My free time is rather limited at the moment, but I'll try to get this into a release within the next month.

@Uberi Uberi merged commit 0202212 into Uberi:master Oct 8, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment