bambocher / pocketsphinx-python

Python interface to CMU Sphinxbase and Pocketsphinx libraries
https://pypi.python.org/pypi/pocketsphinx
Other
374 stars 187 forks source link

Keyword Recognition Not Instantly Closable in Loop #51

Closed awesomepgm closed 4 years ago

awesomepgm commented 4 years ago

The LiveSpeech call used to detect keywords live cannot be closed until one of the keywords is said again. This may be an oversight on my part but I have tried everything to close the for loop and so far nothing has worked. This is a simplified version of what I am doing:

from pocketsphinx import LiveSpeech
speech = LiveSpeech()
for phrase in speech: print(phrase)
#runs at the same time as:
if QUIT:
 #close script
 #there are many other ways to do this but I thought that raising an error would work but it still needs one more input to work
 speech = 1

I think a good addition to change this would be a streaming system like that of pyaudio to recognize sound live with a callback. This might already exist if so, I'm sorry.

awesomepgm commented 4 years ago

I forgot to mention that I have used the .stop method but it gives an error so it is not great for my purpose as it would mess up the flow of the code.

awesomepgm commented 4 years ago

Turns out this was a problem with the multiprocessing library. However, I still believe that a stream module should be added.