PocketSphinx 5prealpha
ps_lattice.h
Go to the documentation of this file.
1/* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/* ====================================================================
3 * Copyright (c) 2008 Carnegie Mellon University. All rights
4 * reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 *
18 * This work was supported in part by funding from the Defense Advanced
19 * Research Projects Agency and the National Science Foundation of the
20 * United States of America, and the CMU Sphinx Speech Consortium.
21 *
22 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
23 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
26 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 * ====================================================================
35 *
36 */
37
42#ifndef __PS_LATTICE_H__
43#define __PS_LATTICE_H__
44
45/* SphinxBase headers. */
46#include <sphinxbase/prim_type.h>
47#include <sphinxbase/ngram_model.h>
48
49/* PocketSphinx headers. */
50#include <pocketsphinx_export.h>
51
52#ifdef __cplusplus
53extern "C" {
54#endif
55#if 0
56}
57#endif
58
63
71
75typedef struct ps_latnode_s ps_latnode_iter_t; /* pay no attention to the man behind the curtain */
76
84
89
90/* Forward declaration needed to avoid circular includes */
91struct ps_decoder_s;
92
100POCKETSPHINX_EXPORT
102 char const *file);
103
113POCKETSPHINX_EXPORT
115
121POCKETSPHINX_EXPORT
123
129POCKETSPHINX_EXPORT
130int ps_lattice_write(ps_lattice_t *dag, char const *filename);
131
137POCKETSPHINX_EXPORT
138int ps_lattice_write_htk(ps_lattice_t *dag, char const *filename);
139
148POCKETSPHINX_EXPORT
149logmath_t *ps_lattice_get_logmath(ps_lattice_t *dag);
150
151
161POCKETSPHINX_EXPORT
163
169POCKETSPHINX_EXPORT
171
176POCKETSPHINX_EXPORT
178
182POCKETSPHINX_EXPORT
184
193POCKETSPHINX_EXPORT
194int ps_latnode_times(ps_latnode_t *node, int16 *out_fef, int16 *out_lef);
195
203POCKETSPHINX_EXPORT
204char const *ps_latnode_word(ps_lattice_t *dag, ps_latnode_t *node);
205
213POCKETSPHINX_EXPORT
214char const *ps_latnode_baseword(ps_lattice_t *dag, ps_latnode_t *node);
215
222POCKETSPHINX_EXPORT
224
231POCKETSPHINX_EXPORT
233
245POCKETSPHINX_EXPORT
247 ps_latlink_t **out_link);
248
255POCKETSPHINX_EXPORT
257
262POCKETSPHINX_EXPORT
264
268POCKETSPHINX_EXPORT
270
281POCKETSPHINX_EXPORT
282int ps_latlink_times(ps_latlink_t *link, int16 *out_sf);
283
291POCKETSPHINX_EXPORT
293
301POCKETSPHINX_EXPORT
302char const *ps_latlink_word(ps_lattice_t *dag, ps_latlink_t *link);
303
311POCKETSPHINX_EXPORT
312char const *ps_latlink_baseword(ps_lattice_t *dag, ps_latlink_t *link);
313
320POCKETSPHINX_EXPORT
322
333POCKETSPHINX_EXPORT
334int32 ps_latlink_prob(ps_lattice_t *dag, ps_latlink_t *link, int32 *out_ascr);
335
340POCKETSPHINX_EXPORT
342 int32 score, int32 ef);
343
359POCKETSPHINX_EXPORT
361
369POCKETSPHINX_EXPORT
371
382POCKETSPHINX_EXPORT
384
392POCKETSPHINX_EXPORT
394
403POCKETSPHINX_EXPORT
404ps_latlink_t *ps_lattice_bestpath(ps_lattice_t *dag, ngram_model_t *lmset,
405 float32 lwf, float32 ascale);
406
414POCKETSPHINX_EXPORT
415int32 ps_lattice_posterior(ps_lattice_t *dag, ngram_model_t *lmset,
416 float32 ascale);
417
429POCKETSPHINX_EXPORT
430int32 ps_lattice_posterior_prune(ps_lattice_t *dag, int32 beam);
431
432#ifdef NOT_IMPLEMENTED_YET
439POCKETSPHINX_EXPORT
440int32 ps_lattice_ngram_expand(ps_lattice_t *dag, ngram_model_t *lm);
441#endif
442
449POCKETSPHINX_EXPORT
451
452#ifdef __cplusplus
453}
454#endif
455
456#endif /* __PS_LATTICE_H__ */
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.
Definition: ps_lattice.c:1091
POCKETSPHINX_EXPORT ps_latlink_t * ps_latlink_pred(ps_latlink_t *link)
Get predecessor link in best path.
Definition: ps_lattice.c:816
POCKETSPHINX_EXPORT logmath_t * ps_lattice_get_logmath(ps_lattice_t *dag)
Get the log-math computation object for this lattice.
Definition: ps_lattice.c:682
POCKETSPHINX_EXPORT int32 ps_lattice_posterior_prune(ps_lattice_t *dag, int32 beam)
Prune all links (and associated nodes) below a certain posterior probability.
Definition: ps_lattice.c:1524
POCKETSPHINX_EXPORT ps_latlink_iter_t * ps_latlink_iter_next(ps_latlink_iter_t *itor)
Get next link from a lattice link iterator.
Definition: ps_lattice.c:761
POCKETSPHINX_EXPORT ps_latnode_t * ps_latnode_iter_node(ps_latnode_iter_t *itor)
Get node from iterator.
Definition: ps_lattice.c:706
POCKETSPHINX_EXPORT int ps_lattice_write(ps_lattice_t *dag, char const *filename)
Write a lattice to disk.
Definition: ps_lattice.c:210
POCKETSPHINX_EXPORT int ps_lattice_free(ps_lattice_t *dag)
Free a lattice.
Definition: ps_lattice.c:665
POCKETSPHINX_EXPORT int ps_latnode_times(ps_latnode_t *node, int16 *out_fef, int16 *out_lef)
Get start and end time range for a node.
Definition: ps_lattice.c:712
POCKETSPHINX_EXPORT int ps_lattice_n_frames(ps_lattice_t *dag)
Get the number of frames in the lattice.
Definition: ps_lattice.c:633
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,...
Definition: ps_lattice.c:65
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.
Definition: ps_lattice.c:1148
POCKETSPHINX_EXPORT int32 ps_latnode_prob(ps_lattice_t *dag, ps_latnode_t *node, ps_latlink_t **out_link)
Get best posterior probability and associated acoustic score from a lattice node.
Definition: ps_lattice.c:732
POCKETSPHINX_EXPORT ps_latnode_iter_t * ps_latnode_iter_next(ps_latnode_iter_t *itor)
Move to next node in iteration.
Definition: ps_lattice.c:694
POCKETSPHINX_EXPORT ps_lattice_t * ps_lattice_read(struct ps_decoder_s *ps, char const *file)
Read a lattice from a file on disk.
Definition: ps_lattice.c:387
POCKETSPHINX_EXPORT ps_latlink_t * ps_latlink_iter_link(ps_latlink_iter_t *itor)
Get link from iterator.
Definition: ps_lattice.c:773
POCKETSPHINX_EXPORT int32 ps_lattice_posterior(ps_lattice_t *dag, ngram_model_t *lmset, float32 ascale)
Calculate link posterior probabilities on a word graph.
Definition: ps_lattice.c:1446
POCKETSPHINX_EXPORT char const * ps_latlink_word(ps_lattice_t *dag, ps_latlink_t *link)
Get word string from a lattice link.
Definition: ps_lattice.c:800
POCKETSPHINX_EXPORT ps_latlink_iter_t * ps_latnode_exits(ps_latnode_t *node)
Iterate over exits from this node.
Definition: ps_lattice.c:749
POCKETSPHINX_EXPORT void ps_latlink_iter_free(ps_latlink_iter_t *itor)
Stop iterating over links.
Definition: ps_lattice.c:767
POCKETSPHINX_EXPORT int32 ps_latlink_prob(ps_lattice_t *dag, ps_latlink_t *link, int32 *out_ascr)
Get acoustic score and posterior probability from a lattice link.
Definition: ps_lattice.c:822
POCKETSPHINX_EXPORT char const * ps_latlink_baseword(ps_lattice_t *dag, ps_latlink_t *link)
Get base word string from a lattice link.
Definition: ps_lattice.c:808
POCKETSPHINX_EXPORT char const * ps_latnode_word(ps_lattice_t *dag, ps_latnode_t *node)
Get word string for this node.
Definition: ps_lattice.c:720
POCKETSPHINX_EXPORT ps_latlink_iter_t * ps_latnode_entries(ps_latnode_t *node)
Iterate over entries to this node.
Definition: ps_lattice.c:755
POCKETSPHINX_EXPORT ps_lattice_t * ps_lattice_retain(ps_lattice_t *dag)
Retain a lattice.
Definition: ps_lattice.c:658
POCKETSPHINX_EXPORT ps_latlink_t * ps_lattice_reverse_next(ps_lattice_t *dag, ps_latnode_t *start)
Get the next link in reverse traversal.
Definition: ps_lattice.c:1173
POCKETSPHINX_EXPORT ps_latlink_t * ps_lattice_traverse_next(ps_lattice_t *dag, ps_latnode_t *end)
Get the next link in forward traversal.
Definition: ps_lattice.c:1117
POCKETSPHINX_EXPORT void ps_latnode_iter_free(ps_latnode_iter_t *itor)
Stop iterating over nodes.
Definition: ps_lattice.c:700
POCKETSPHINX_EXPORT int ps_latlink_times(ps_latlink_t *link, int16 *out_sf)
Get start and end times from a lattice link.
Definition: ps_lattice.c:779
POCKETSPHINX_EXPORT ps_latnode_t * ps_latlink_nodes(ps_latlink_t *link, ps_latnode_t **out_src)
Get destination and source nodes from a lattice link.
Definition: ps_lattice.c:793
POCKETSPHINX_EXPORT ps_latnode_iter_t * ps_latnode_iter(ps_lattice_t *dag)
Start iterating over nodes in the lattice.
Definition: ps_lattice.c:688
POCKETSPHINX_EXPORT int ps_lattice_write_htk(ps_lattice_t *dag, char const *filename)
Write a lattice to disk in HTK format.
Definition: ps_lattice.c:270
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.
Definition: ps_lattice.c:1215
POCKETSPHINX_EXPORT char const * ps_latnode_baseword(ps_lattice_t *dag, ps_latnode_t *node)
Get base word string for this node.
Definition: ps_lattice.c:726
Decoder object.
Word graph structure used in bestpath/nbest search.