bambocher/pocketsphinx-python

Multiple keywords support?

Opened this issue · 8 comments

I couldn't find it in the documentation, but is there support for a list of keywords? i.e. pocketsphinx_continuous -kws keyword.list ....

If not, is it something that could be added?

speech = LiveSpeech(kws='file.list')

should work

Hello, I using pocketsphinx and have the same problem.
speech = LiveSpeech(kws='key.list')
my key list is very small:
OPEN /1e-1/ TURN /1e-20/ STOP /1e-20/
my code picks up ends up returning any words and not just those on my list. I do not know what to do to continue.

Hello, I using pocketsphinx and have the same problem.
speech = LiveSpeech(kws='key.list')
my key list is very small:
OPEN /1e-1/ TURN /1e-20/ STOP /1e-20/
my code picks up ends up returning any words and not just those on my list. I do not know what to do to continue.

Did you try this? From the documentation:

for phrase in speech: print(phrase.segments(detailed=True))

I too am having a issue with this. @DanielMzLz I tried what you posted and it does the opposite of what I am trying to do.

keywords=['word', 'phrase one', 'something else', 'test', 'etc']
speech = LiveSpeech(keyphrase=keywords)
print(speech)

I want the multiple keyphrases so that the voice recognition is more accurate.

Please help. Thanks.

EDIT: the above code doesn't work. I was hoping that it would.

@https://github.com/l33tlinuxh4x0r
Your keywords must be in a file with this format:
keyword /1e-1/ # Note that you can put your own custom threshold

Note that you cannot pass in a list.

Multiple keyword support worked for me like this:

speech = LiveSpeech(lm=False, kws='key.list')

had to set lm to False since kws aparently conflicts with lm (https://cmusphinx.github.io/wiki/tutoriallm/)

I too am having a issue with this. @DanielMzLz I tried what you posted and it does the opposite of what I am trying to do.

keywords=['word', 'phrase one', 'something else', 'test', 'etc']
speech = LiveSpeech(keyphrase=keywords)
print(speech)

I want the multiple keyphrases so that the voice recognition is more accurate.

Please help. Thanks.

EDIT: the above code doesn't work. I was hoping that it would.

Tried the solutions mentioned above and had the exact same problem as you. But the following worked for me, it involves defining a pronunciation dictionary (explained here https://miguelmota.com/bytes/pocketsphinx-continuous-multiple-keywords/)

speech = LiveSpeech(lm=False, kws='key.list', dic='key.dict')

Hope this helps someone

Did you tried this?
`from pocketsphinx import LiveSpeech

keywords = ["yes", "no", "maybe", "I don't know"]

for keyword in keywords:
live_speech = LiveSpeech(lm=False, keyphrase=keyword, kws_threshold=1e-20)
for phrase in live_speech:
print(phrase)`