bambocher / pocketsphinx-python

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

Multiple keywords support? #37

Open tlrobinson opened 6 years ago

tlrobinson commented 6 years ago

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?

nshmyrev commented 6 years ago

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

should work

emanuelqueiroga commented 5 years ago

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.

danielml-mx commented 5 years ago

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))

l33tlinuxh4x0r commented 4 years ago

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.

jfuruness commented 4 years ago

@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.

kultzak commented 3 years ago

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/)

JosephDillman commented 3 years ago

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

jctelo commented 1 year ago

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)`