PocketSphinx  5.0.0
A small speech recognizer
Public Member Functions | List of all members
fsg_model_t Struct Reference

Finite-state grammar. More...

#include <pocketsphinx/model.h>

Public Member Functions

POCKETSPHINX_EXPORT fsg_model_tjsgf_read_file (const char *file, logmath_t *lmath, float32 lw)
 
POCKETSPHINX_EXPORT fsg_model_tjsgf_read_string (const char *string, logmath_t *lmath, float32 lw)
 
POCKETSPHINX_EXPORT fsg_model_tfsg_model_retain (fsg_model_t *fsg)
 
POCKETSPHINX_EXPORT int fsg_model_free (fsg_model_t *fsg)
 
POCKETSPHINX_EXPORT fsg_model_tfsg_model_readfile (const char *file, logmath_t *lmath, float32 lw)
 
POCKETSPHINX_EXPORT fsg_model_tfsg_model_read (FILE *fp, logmath_t *lmath, float32 lw)
 
POCKETSPHINX_EXPORT int fsg_model_accept (fsg_model_t *fsg, char const *words)
 
POCKETSPHINX_EXPORT void fsg_model_write (fsg_model_t *fsg, FILE *fp)
 
POCKETSPHINX_EXPORT void fsg_model_writefile (fsg_model_t *fsg, char const *file)
 
POCKETSPHINX_EXPORT void fsg_model_write_fsm (fsg_model_t *fsg, FILE *fp)
 
POCKETSPHINX_EXPORT void fsg_model_writefile_fsm (fsg_model_t *fsg, char const *file)
 
POCKETSPHINX_EXPORT void fsg_model_write_symtab (fsg_model_t *fsg, FILE *file)
 
POCKETSPHINX_EXPORT void fsg_model_writefile_symtab (fsg_model_t *fsg, char const *file)
 

Detailed Description

Finite-state grammar.

States are simply integers 0..n_state-1. A transition emits a word and has a given probability of being taken. There can also be null or epsilon transitions, with no associated emitted word.

Member Function Documentation

◆ jsgf_read_file()

POCKETSPHINX_EXPORT fsg_model_t * jsgf_read_file ( const char *  file,
logmath_t lmath,
float32  lw 
)

Read JSGF from file and return FSG object from it.

This function looks for a first public rule in jsgf and constructs JSGF from it.

◆ jsgf_read_string()

POCKETSPHINX_EXPORT fsg_model_t * jsgf_read_string ( const char *  string,
logmath_t lmath,
float32  lw 
)

Read JSGF from string and return FSG object from it.

This function looks for a first public rule in jsgf and constructs JSGF from it.

◆ fsg_model_retain()

POCKETSPHINX_EXPORT fsg_model_t * fsg_model_retain ( fsg_model_t fsg)

Retain ownership of an FSG.

Returns
Pointer to retained FSG.

◆ fsg_model_free()

POCKETSPHINX_EXPORT int fsg_model_free ( fsg_model_t fsg)

Free the given word FSG.

Returns
new reference count (0 if freed completely)

◆ fsg_model_readfile()

POCKETSPHINX_EXPORT fsg_model_t * fsg_model_readfile ( const char *  file,
logmath_t lmath,
float32  lw 
)

Read a word FSG from the given file and return a pointer to the structure created. Return NULL if any error occurred.

File format:

  Any number of comment lines; ignored
  FSG_BEGIN [<fsgname>]
  N <#states>
  S <start-state ID>
  F <final-state ID>
  T <from-state> <to-state> <prob> [<word-string>]
  T ...
  ... (any number of state transitions)
  FSG_END
  Any number of comment lines; ignored

The FSG spec begins with the line containing the keyword FSG_BEGIN. It has an optional fsg name string. If not present, the FSG has the empty string as its name.

Following the FSG_BEGIN declaration is the number of states, the start state, and the final state, each on a separate line. States are numbered in the range [0 .. <numberofstate>-1].

These are followed by all the state transitions, each on a separate line, and terminated by the FSG_END line. A state transition has the given probability of being taken, and emits the given word. The word emission is optional; if word-string omitted, it is an epsilon or null transition.

Comments can also be embedded within the FSG body proper (i.e. between FSG_BEGIN and FSG_END): any line with a # character in col 1 is treated as a comment line.

Return value: a new fsg_model_t structure if the file is successfully read, NULL otherwise.

◆ fsg_model_read()

POCKETSPHINX_EXPORT fsg_model_t * fsg_model_read ( FILE *  fp,
logmath_t lmath,
float32  lw 
)

Like fsg_model_readfile(), but from an already open stream.

◆ fsg_model_accept()

POCKETSPHINX_EXPORT int fsg_model_accept ( fsg_model_t fsg,
char const *  words 
)

Check that an FSG accepts a word sequence

Parameters
wordsWhitespace-separated word sequence
Returns
1 if accepts, 0 if not.

◆ fsg_model_write()

POCKETSPHINX_EXPORT void fsg_model_write ( fsg_model_t fsg,
FILE *  fp 
)

Write FSG to a file.

◆ fsg_model_writefile()

POCKETSPHINX_EXPORT void fsg_model_writefile ( fsg_model_t fsg,
char const *  file 
)

Write FSG to a file.

◆ fsg_model_write_fsm()

POCKETSPHINX_EXPORT void fsg_model_write_fsm ( fsg_model_t fsg,
FILE *  fp 
)

Write FSG to a file in AT&T FSM format.

◆ fsg_model_writefile_fsm()

POCKETSPHINX_EXPORT void fsg_model_writefile_fsm ( fsg_model_t fsg,
char const *  file 
)

Write FSG to a file in AT&T FSM format.

◆ fsg_model_write_symtab()

POCKETSPHINX_EXPORT void fsg_model_write_symtab ( fsg_model_t fsg,
FILE *  file 
)

Write FSG symbol table to a file (for AT&T FSM)

◆ fsg_model_writefile_symtab()

POCKETSPHINX_EXPORT void fsg_model_writefile_symtab ( fsg_model_t fsg,
char const *  file 
)

Write FSG symbol table to a file (for AT&T FSM)


The documentation for this struct was generated from the following file: