cmusphinx / pocketsphinx

A small speech recognizer
Other
3.9k stars 714 forks source link

How to use search module API? #314

Closed roccopersico99 closed 1 year ago

roccopersico99 commented 1 year ago

I am having some trouble updating my old keyphrase search implementation to work with PocketSphinx5. I applied the changes mentioned in the FAQ such as swapping 'ps_set_search' -> 'ps_activate_search' and swapping 'ps_set_keyphrase' -> 'ps_add_keyphrase' but both functions always seem to return < 0. I even tried using the ps_add_kws and passing in a path to a keyphrases.list file that contains the keyphrases needed to be detected but both methods seem to fail. Is there any more info or examples that can be offered on how to use the search API as the documentation around it is very minimal with no examples. Thanks!

roccopersico99 commented 1 year ago

Here is the mentioned keyphrases.list file and the dictionary im using (both changed to .txt so they could be uploaded here) keyphrases.txt cmudict-en-us.txt

roccopersico99 commented 1 year ago

I think the issue more boils down to needing an example of using the Keyword mode in general, as live.c and simple.c do not use this mode.

dhdaines commented 1 year ago

Hi! Yes, I think there is lacking documentation there indeed. There is something of an example in the unit tests (both in C and Python) but it needs to be brought into the actual documentation:

https://github.com/cmusphinx/pocketsphinx/blob/master/test/unit/test_keyphrase.c https://github.com/cmusphinx/pocketsphinx/blob/master/cython/test/kws_test.py

This also doesn't really describe the API for doing it other than from a file.