Enaid
Enaid

Reputation: 305

How to retrieve the rule names of words using a jsgf grammar file with pocketsphinx in Python?

I am using pocketpshinx in python for speech recognition using a JSGF grammar file. The grammar is composed of rules, and speech is matched to those rules to be recognized.

The recognition works well, but I can´t seem to find how to retrieve the rule names for each word. I am not interested in tags, as I read it is not implemented in pocketsphinx, just in the rule names. For example, with this simple grammar file that I just made up :

#JSGF V1.0
grammar my_grammar;
<polite> = please | thank you ;
<command> = go left | wait here;
public <sentence> = <polite> <command> <polite>;

If the recognized speech is "Please wait here thank you", I would like to be able to retrieve the "command" part ("wait here") and manipulate it. I have read that regular expressions can be used, but I don´t really understand if there is already something taking care of that in pocketsphinx (which would be great) or if I have to build something myself. I don´t want to reinvent the wheel if it´s not necessary. =)

Upvotes: 3

Views: 935

Answers (1)

Nikolay Shmyrev
Nikolay Shmyrev

Reputation: 25220

There is nothing for that in pocketsphinx. You can use regular expressions, they are part of Python library, not a part of pocketsphinx.

Upvotes: 0

Related Questions