Finite state grammar
From Sphinx
Contents |
Description
A finite state grammar defines the possible words as well as the possible word orders.
Sphinx4 Example (JSGF)
Sphinx4 uses JSGF, here is a very flat example.
#JSGF V1.0; grammar basic;public <basic> = (apartment) | (base) | (booze) | (cantankerous) | (christ);
and another example to recognize different variations of peoples names:
#JSGF V1.0; grammar contacts; public <contacts> = ((Joe Maynard Smith | Smith Joe | Smith Maynard | Joe Maynard | Smith | Joe) | (Mary Poppins | Poppins Mary | Mary | Poppins))
Sphinx3 Example
Sphinx3 and PocketSphinx use a "lower-level" format for finite state grammars, inherited from Sphinx2. FSG support is somewhat broken in Sphinx3 0.6.3, so 0.7 is recommended. A typical FSG file looks like this:
FSG_BEGIN <fsgname> NUM_STATES 2 START_STATE 0 FINAL_STATE 1 # Transitions TRANSITION 0 0 0.8 FOO TRANSITION 0 1 0.2 TRANSITION 1 1 0.8 BAR TRANSITION 1 1 0.2 FSG_END
However, the current Subversion trunk of sphinxbase contains a JSGF "compiler" which will generate FSG files from JSGF grammars. It can be found in sphinxbase/src/sphinx_jsgf2fsg.
The next releases of PocketSphinx and Sphinx3 will support JSGF "natively".
SRGS support is under investigation, however like all W3C standards it is excessively complex and also contains many requirements (such as network access) which are beyond the scope of a speech recognition system.
Sphinx2 Example
See sphinx2 fsg grammar format
Lumenvox Example
#ABNF 1.0;
language en-US; //use the American English pronunciation dictionary.
mode voice; //the input for this grammar will be spoken words (as opposed to DTMF)
root $deliveryortakeout;
$delivery = delivery:"Delivery";
$takeout = takeout:"Pickup";
$deliveryortakeout = ($delivery | $takeout){$=$$};
