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

Word graph structure used in bestpath/nbest search. More...

#include <pocketsphinx/lattice.h>

Public Member Functions

POCKETSPHINX_EXPORT ps_lattice_tps_lattice_read (struct ps_decoder_s *ps, char const *file)
 
POCKETSPHINX_EXPORT ps_lattice_tps_lattice_retain (ps_lattice_t *dag)
 
POCKETSPHINX_EXPORT int ps_lattice_free (ps_lattice_t *dag)
 
POCKETSPHINX_EXPORT int ps_lattice_write (ps_lattice_t *dag, char const *filename)
 
POCKETSPHINX_EXPORT int ps_lattice_write_htk (ps_lattice_t *dag, char const *filename)
 
POCKETSPHINX_EXPORT logmath_tps_lattice_get_logmath (ps_lattice_t *dag)
 
POCKETSPHINX_EXPORT ps_latnode_iter_tps_latnode_iter (ps_lattice_t *dag)
 
POCKETSPHINX_EXPORT void ps_lattice_link (ps_lattice_t *dag, ps_latnode_t *from, ps_latnode_t *to, int32 score, int32 ef)
 
POCKETSPHINX_EXPORT ps_latlink_tps_lattice_traverse_edges (ps_lattice_t *dag, ps_latnode_t *start, ps_latnode_t *end)
 
POCKETSPHINX_EXPORT ps_latlink_tps_lattice_traverse_next (ps_lattice_t *dag, ps_latnode_t *end)
 
POCKETSPHINX_EXPORT ps_latlink_tps_lattice_reverse_edges (ps_lattice_t *dag, ps_latnode_t *start, ps_latnode_t *end)
 
POCKETSPHINX_EXPORT ps_latlink_tps_lattice_reverse_next (ps_lattice_t *dag, ps_latnode_t *start)
 
POCKETSPHINX_EXPORT ps_latlink_tps_lattice_bestpath (ps_lattice_t *dag, ngram_model_t *lmset, float32 lwf, float32 ascale)
 
POCKETSPHINX_EXPORT int32 ps_lattice_posterior (ps_lattice_t *dag, ngram_model_t *lmset, float32 ascale)
 
POCKETSPHINX_EXPORT int32 ps_lattice_posterior_prune (ps_lattice_t *dag, int32 beam)
 
POCKETSPHINX_EXPORT int ps_lattice_n_frames (ps_lattice_t *dag)
 

Detailed Description

Word graph structure used in bestpath/nbest search.

Member Function Documentation

◆ ps_lattice_read()

POCKETSPHINX_EXPORT ps_lattice_t * ps_lattice_read ( struct ps_decoder_s *  ps,
char const *  file 
)

Read a lattice from a file on disk.

Parameters
psDecoder to use for processing this lattice, or NULL.
filePath to lattice file.
Returns
Newly created lattice, or NULL for failure.

◆ ps_lattice_retain()

POCKETSPHINX_EXPORT ps_lattice_t * ps_lattice_retain ( ps_lattice_t dag)

Retain a lattice.

This function retains ownership of a lattice for the caller, preventing it from being freed automatically. You must call ps_lattice_free() to free it after having called this function.

Returns
pointer to the retained lattice.

◆ ps_lattice_free()

POCKETSPHINX_EXPORT int ps_lattice_free ( ps_lattice_t dag)

Free a lattice.

Returns
new reference count (0 if dag was freed)

◆ ps_lattice_write()

POCKETSPHINX_EXPORT int ps_lattice_write ( ps_lattice_t dag,
char const *  filename 
)

Write a lattice to disk.

Returns
0 for success, <0 on failure.

◆ ps_lattice_write_htk()

POCKETSPHINX_EXPORT int ps_lattice_write_htk ( ps_lattice_t dag,
char const *  filename 
)

Write a lattice to disk in HTK format

Returns
0 for success, <0 on failure.

◆ ps_lattice_get_logmath()

POCKETSPHINX_EXPORT logmath_t * ps_lattice_get_logmath ( ps_lattice_t dag)

Get the log-math computation object for this lattice

Returns
The log-math object for this lattice. The lattice retains ownership of this pointer, so you should not attempt to free it manually. Use logmath_retain() if you wish to reuse it elsewhere.

◆ ps_latnode_iter()

POCKETSPHINX_EXPORT ps_latnode_iter_t * ps_latnode_iter ( ps_lattice_t dag)

Start iterating over nodes in the lattice.

Note
No particular order of traversal is guaranteed, and you should not depend on this.
Parameters
dagLattice to iterate over.
Returns
Iterator over lattice nodes.

◆ ps_lattice_link()

POCKETSPHINX_EXPORT void ps_lattice_link ( ps_lattice_t dag,
ps_latnode_t from,
ps_latnode_t to,
int32  score,
int32  ef 
)

Create a directed link between "from" and "to" nodes, but if a link already exists, choose one with the best link_scr.

◆ ps_lattice_traverse_edges()

POCKETSPHINX_EXPORT ps_latlink_t * ps_lattice_traverse_edges ( ps_lattice_t dag,
ps_latnode_t start,
ps_latnode_t end 
)

Start a forward traversal of edges in a word graph.

Note
A keen eye will notice an inconsistency in this API versus other types of iterators in PocketSphinx. The reason for this is that the traversal algorithm is much more efficient when it is able to modify the lattice structure. Therefore, to avoid giving the impression that multiple traversals are possible at once, no separate iterator structure is provided.
Parameters
dagLattice to be traversed.
startStart node (source) of traversal.
endEnd node (goal) of traversal.
Returns
First link in traversal.

◆ ps_lattice_traverse_next()

POCKETSPHINX_EXPORT ps_latlink_t * ps_lattice_traverse_next ( ps_lattice_t dag,
ps_latnode_t end 
)

Get the next link in forward traversal.

Parameters
dagLattice to be traversed.
endEnd node (goal) of traversal.
Returns
Next link in traversal.

◆ ps_lattice_reverse_edges()

POCKETSPHINX_EXPORT ps_latlink_t * ps_lattice_reverse_edges ( ps_lattice_t dag,
ps_latnode_t start,
ps_latnode_t end 
)

Start a reverse traversal of edges in a word graph.

Note
See ps_lattice_traverse_edges() for why this API is the way it is.
Parameters
dagLattice to be traversed.
startStart node (goal) of traversal.
endEnd node (source) of traversal.
Returns
First link in traversal.

◆ ps_lattice_reverse_next()

POCKETSPHINX_EXPORT ps_latlink_t * ps_lattice_reverse_next ( ps_lattice_t dag,
ps_latnode_t start 
)

Get the next link in reverse traversal.

Parameters
dagLattice to be traversed.
startStart node (goal) of traversal.
Returns
Next link in traversal.

◆ ps_lattice_bestpath()

POCKETSPHINX_EXPORT ps_latlink_t * ps_lattice_bestpath ( ps_lattice_t dag,
ngram_model_t lmset,
float32  lwf,
float32  ascale 
)

Do N-Gram based best-path search on a word graph.

This function calculates both the best path as well as the forward probability used in confidence estimation.

Returns
Final link in best path, NULL on error.

◆ ps_lattice_posterior()

POCKETSPHINX_EXPORT int32 ps_lattice_posterior ( ps_lattice_t dag,
ngram_model_t lmset,
float32  ascale 
)

Calculate link posterior probabilities on a word graph.

This function assumes that bestpath search has already been done.

Returns
Posterior probability of the utterance as a whole.

◆ ps_lattice_posterior_prune()

POCKETSPHINX_EXPORT int32 ps_lattice_posterior_prune ( ps_lattice_t dag,
int32  beam 
)

Prune all links (and associated nodes) below a certain posterior probability.

This function assumes that ps_lattice_posterior() has already been called.

Parameters
beamMinimum posterior probability for links. This is expressed in the log-base used in the decoder. To convert from linear floating-point, use logmath_log(ps_lattice_get_logmath(), prob).
Returns
number of arcs removed.

◆ ps_lattice_n_frames()

POCKETSPHINX_EXPORT int ps_lattice_n_frames ( ps_lattice_t dag)

Get the number of frames in the lattice.

Parameters
dagThe lattice in question.
Returns
Number of frames in this lattice.

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