speech_recognition icon indicating copy to clipboard operation
speech_recognition copied to clipboard

Script stuck on hotword detection

Open furqanahmedmtbc opened this issue 7 years ago • 2 comments

Steps to reproduce

I try to run the following script but it seems it is stuck on wake-word detection. I have spoken multiple times but the script does not seem to recognize the wake-word. (Note: The recognition works fine without the wake-word part, It just seems like the addition of wakeword requirement is not working.)

I'm using the Google cloud Speech API on a Raspberry Pi 3.

Code:

pmdl = ['/home/pi/AoD_Final/V4/Squeak.pmdl']
sbLoc = '/home/pi/AoD_Final/V4/'
sbCfg = (sbLoc,pmdl)

print(sbCfg)

# use the audio file as the audio source
mic = sr.Microphone(device_index=3)
r = sr.Recognizer()


print("A moment of silence, please...")
with mic as source:
    r.adjust_for_ambient_noise(source)
    print("Set minimum energy threshold to {}".format(r.energy_threshold))
    
with mic as source:
    r.adjust_for_ambient_noise(source)
    #r.snowboy_wait_for_hot_word(source, "/AoD_Final/V4", "Squeak.pmdl", source, timeout=None)
    audio = r.listen(source,snowboy_configuration=("/home/pi/AoD_Final/V4",["/home/pi/AoD_Final/V4/Squeak.pmdl"]))
    #audio = r.listen(source,snowboy_configuration=sbCfg)
    #audio = r.listen(source)

-------------------------Output-------------------------------------------------------------------

attempt to connect to server failed
A moment of silence, please...
Set minimum energy threshold to 817.50242197
^CTraceback (most recent call last):
  File "with_listen.py", line 31, in <module>
    audio = r.listen(source,snowboy_configuration=("/home/pi/AoD_Final/V4",["/home/pi/AoD_Final/V4/Squeak.pmdl"]))
  File "/home/pi/.local/lib/python2.7/site-packages/speech_recognition/__init__.py", line 638, in listen
    buffer, delta_time = self.snowboy_wait_for_hot_word(snowboy_location, snowboy_hot_word_files, source, timeout)
  File "/home/pi/.local/lib/python2.7/site-packages/speech_recognition/__init__.py", line 573, in snowboy_wait_for_hot_word
    snowboy_result = detector.RunDetection(b"".join(resampled_frames))
  File "/home/pi/AoD_Final/V4/snowboydetect.py", line 111, in RunDetection
    return _snowboydetect.SnowboyDetect_RunDetection(self, *args)
KeyboardInterrupt


furqanahmedmtbc avatar Dec 24 '18 10:12 furqanahmedmtbc

I did some digging around. Looks like the scrip is stuck on snowboy_result = detector.RunDetection(b"".join(resampled_frames)) in the speech recognition init file. The "snowboy_result" value remains 0 even after speaking into the mic multiple times. The hotword is supposed to be detected when this value goes above 0. Any idea how I can solve this issue?

furqanahmedmtbc avatar Dec 26 '18 07:12 furqanahmedmtbc

https://github.com/Uberi/speech_recognition/issues/329

achen88 avatar Feb 11 '22 22:02 achen88