3

I use the following JSGF file with pocketsphinx (in french sorry):

#JSGF V1.0;
/**
* JSGF Grammar for music
*/
grammar music;

<launch_app>    = lance | ouvre;
<launch_radio>  = commence | débute | démarre;                                                      
<launch_artist> = met (du) | joue;

<app_list>      = spotify | youtube | soundcloud | deezer;
<radio_list>    = rock | folk | pop | classique | métal | triste | joyeuse | détendu;
<artist_list>   = moby | lori | kyo | shakira | pantera | mozart;

<name>  = music;

<radio_command> = <name> <launch_radio> une radio <radio_list>;
<app_command>   = <name> <launch_app> <app_list>;
<artist_command> = <name> <launch_artist> <artist_list>;

public <final_rule> = <radio_command> | <app_command> | <artist_command>;

And it perfectly works. But if I remove the <final_rule> tag and use multiple public keywords instead, like this:

#JSGF V1.0;
/**
* JSGF Grammar for music
*/
grammar music;

<launch_app>    = lance | ouvre;
<launch_radio>  = commence | débute | démarre;                                                      
<launch_artist> = met (du) | joue;

<app_list>      = spotify | youtube | soundcloud | deezer;
<radio_list>    = rock | folk | pop | classique | métal | triste | joyeuse | détendu;
<artist_list>   = moby | lori | kyo | shakira | pantera | mozart;

<name>  = music;

public <radio_command> = <name> <launch_radio> une radio <radio_list>;
public <app_command>   = <name> <launch_app> <app_list>;
public <artist_command> = <name> <launch_artist> <artist_list>;

pocketsphinx only recognize one of the three public rules, regardless what I say. I find this behavior strange because pocketsphinx don't give me errors while running with this grammar file. Does a JSGF file only need one public keyword or is it link to pocketshphinx ?

Jérémy Pouyet
  • 1,989
  • 6
  • 28
  • 55

1 Answers1

2

Yes, pocketsphinx recognizes just the first rule by default. If you want to use other rules, there is -toprule parameter in config or name parameter in API.

If you want to recognize multiple choices, you can construct grammar in the way that there is a final rule constructed as a choice of all the rules you need:

 public <command> = <artist> | <music> | <action> ;
Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87
  • Do you know why they have made this choice ? – Jérémy Pouyet Aug 27 '15 at 20:04
  • This is from JSGF standard specification http://www.w3.org/TR/jsgf One rule might be "active" and others could be selected as "active" in recognizer. – Nikolay Shmyrev Aug 27 '15 at 20:13
  • @NikolayShmyrev JSGF standard does not require that there be only one public rule per grammar. It does say that one rule "can" be active, but it does not restrict to just one public rule. In fact, in section 5.1 there is an example given, which has exactly two public rules: https://www.w3.org/TR/jsgf/#17971. However, that example is in turn imported from another grammar with just one public rule. – jotadepicas May 21 '16 at 03:51
  • @jotadepicas, sure, I wrote that one rule is active in pocketsphinx, others could be selected if they are public. – Nikolay Shmyrev May 21 '16 at 07:35