Solvedsnowboy Call start() again after terminate()

Hi,

im trying to add snowboy to a personal assistant app i've been working on but to be able to record the audio i first need to terminate all recording streams from snowboy otherwise i get an Audio Deivce Busy Error.

After accessing detector.terminate() I can finally record my command and the python file processes it correctly. My only problem is, that while the prog loops detector.start(...) does not work anymore.

Is there a way to reenable detector.start(...) so snowboy listens for the Hotword and then kill everything with detector.terminate() (And so on and on)?

Thanks :)

23 Answers

✔️Accepted Answer

Yes that should be easy, just move the last two lines in HotwordDetector.__init__() of snowboydecoder.py:

    self.audio = pyaudio.PyAudio()
    self.stream_in = self.audio.open(
        input=True, output=False,
        format=self.audio.get_format_from_width(
            self.detector.BitsPerSample() / 8),
        channels=self.detector.NumChannels(),
        rate=self.detector.SampleRate(),
        frames_per_buffer=2048,
        stream_callback=audio_callback)

down to the start of the start() function, then you can repeatedly call terminate() and start()!

Related Issues:

3
snowboy Call start() again after terminate()
Yes that should be easy just move the last two lines in HotwordDetector.__init__() of snowboydecoder...