PocketSphinx  0.6
include/ps_lattice.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
00002 /* ====================================================================
00003  * Copyright (c) 2008 Carnegie Mellon University.  All rights
00004  * reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer. 
00012  *
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in
00015  *    the documentation and/or other materials provided with the
00016  *    distribution.
00017  *
00018  * This work was supported in part by funding from the Defense Advanced 
00019  * Research Projects Agency and the National Science Foundation of the 
00020  * United States of America, and the CMU Sphinx Speech Consortium.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 
00023  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
00024  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00025  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
00026  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00027  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
00028  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
00029  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
00030  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00031  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00032  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  * ====================================================================
00035  *
00036  */
00037 
00042 #ifndef __PS_LATTICE_H__
00043 #define __PS_LATTICE_H__
00044 
00045 /* SphinxBase headers. */
00046 #include <sphinxbase/prim_type.h>
00047 #include <sphinxbase/ngram_model.h>
00048 
00049 /* PocketSphinx headers. */
00050 #include <pocketsphinx_export.h>
00051 
00055 typedef struct ps_lattice_s ps_lattice_t;
00056 
00063 typedef struct ps_latnode_s ps_latnode_t;
00064 
00068 typedef struct ps_latnode_s ps_latnode_iter_t; /* pay no attention to the man behind the curtain */
00069 
00076 typedef struct ps_latlink_s ps_latlink_t;
00077 
00081 typedef struct latlink_list_s ps_latlink_iter_t;
00082 
00083 /* Forward declaration needed to avoid circular includes */
00084 struct ps_decoder_s;
00085 
00093 POCKETSPHINX_EXPORT
00094 ps_lattice_t *ps_lattice_read(struct ps_decoder_s *ps,
00095                               char const *file);
00096 
00106 POCKETSPHINX_EXPORT
00107 ps_lattice_t *ps_lattice_retain(ps_lattice_t *dag);
00108 
00114 POCKETSPHINX_EXPORT
00115 int ps_lattice_free(ps_lattice_t *dag);
00116 
00122 POCKETSPHINX_EXPORT
00123 int ps_lattice_write(ps_lattice_t *dag, char const *filename);
00124 
00130 POCKETSPHINX_EXPORT
00131 int ps_lattice_write_htk(ps_lattice_t *dag, char const *filename);
00132 
00141 POCKETSPHINX_EXPORT
00142 logmath_t *ps_lattice_get_logmath(ps_lattice_t *dag);
00143 
00144 
00154 POCKETSPHINX_EXPORT
00155 ps_latnode_iter_t *ps_latnode_iter(ps_lattice_t *dag);
00156 
00162 POCKETSPHINX_EXPORT
00163 ps_latnode_iter_t *ps_latnode_iter_next(ps_latnode_iter_t *itor);
00164 
00169 POCKETSPHINX_EXPORT
00170 void ps_latnode_iter_free(ps_latnode_iter_t *itor);
00171 
00175 POCKETSPHINX_EXPORT
00176 ps_latnode_t *ps_latnode_iter_node(ps_latnode_iter_t *itor);
00177 
00186 POCKETSPHINX_EXPORT
00187 int ps_latnode_times(ps_latnode_t *node, int16 *out_fef, int16 *out_lef);
00188 
00196 POCKETSPHINX_EXPORT
00197 char const *ps_latnode_word(ps_lattice_t *dag, ps_latnode_t *node);
00198 
00206 POCKETSPHINX_EXPORT
00207 char const *ps_latnode_baseword(ps_lattice_t *dag, ps_latnode_t *node);
00208 
00215 POCKETSPHINX_EXPORT
00216 ps_latlink_iter_t *ps_latnode_exits(ps_latnode_t *node);
00217 
00224 POCKETSPHINX_EXPORT
00225 ps_latlink_iter_t *ps_latnode_entries(ps_latnode_t *node);
00226 
00238 POCKETSPHINX_EXPORT
00239 int32 ps_latnode_prob(ps_lattice_t *dag, ps_latnode_t *node,
00240                       ps_latlink_t **out_link);
00241 
00248 POCKETSPHINX_EXPORT
00249 ps_latlink_iter_t *ps_latlink_iter_next(ps_latlink_iter_t *itor);
00250 
00255 POCKETSPHINX_EXPORT
00256 void ps_latlink_iter_free(ps_latlink_iter_t *itor);
00257 
00261 POCKETSPHINX_EXPORT
00262 ps_latlink_t *ps_latlink_iter_link(ps_latlink_iter_t *itor);
00263 
00274 POCKETSPHINX_EXPORT
00275 int ps_latlink_times(ps_latlink_t *link, int16 *out_sf);
00276 
00284 POCKETSPHINX_EXPORT
00285 ps_latnode_t *ps_latlink_nodes(ps_latlink_t *link, ps_latnode_t **out_src);
00286 
00294 POCKETSPHINX_EXPORT
00295 char const *ps_latlink_word(ps_lattice_t *dag, ps_latlink_t *link);
00296 
00304 POCKETSPHINX_EXPORT
00305 char const *ps_latlink_baseword(ps_lattice_t *dag, ps_latlink_t *link);
00306 
00313 POCKETSPHINX_EXPORT
00314 ps_latlink_t *ps_latlink_pred(ps_latlink_t *link);
00315 
00326 POCKETSPHINX_EXPORT
00327 int32 ps_latlink_prob(ps_lattice_t *dag, ps_latlink_t *link, int32 *out_ascr);
00328 
00333 POCKETSPHINX_EXPORT
00334 void ps_lattice_link(ps_lattice_t *dag, ps_latnode_t *from, ps_latnode_t *to,
00335                      int32 score, int32 ef);
00336 
00352 POCKETSPHINX_EXPORT
00353 ps_latlink_t *ps_lattice_traverse_edges(ps_lattice_t *dag, ps_latnode_t *start, ps_latnode_t *end);
00354 
00362 POCKETSPHINX_EXPORT
00363 ps_latlink_t *ps_lattice_traverse_next(ps_lattice_t *dag, ps_latnode_t *end);
00364 
00375 POCKETSPHINX_EXPORT
00376 ps_latlink_t *ps_lattice_reverse_edges(ps_lattice_t *dag, ps_latnode_t *start, ps_latnode_t *end);
00377 
00385 POCKETSPHINX_EXPORT
00386 ps_latlink_t *ps_lattice_reverse_next(ps_lattice_t *dag, ps_latnode_t *start);
00387 
00396 POCKETSPHINX_EXPORT
00397 ps_latlink_t *ps_lattice_bestpath(ps_lattice_t *dag, ngram_model_t *lmset,
00398                                   float32 lwf, float32 ascale);
00399 
00407 POCKETSPHINX_EXPORT
00408 int32 ps_lattice_posterior(ps_lattice_t *dag, ngram_model_t *lmset,
00409                            float32 ascale);
00410 
00422 POCKETSPHINX_EXPORT
00423 int32 ps_lattice_posterior_prune(ps_lattice_t *dag, int32 beam);
00424 
00425 #ifdef NOT_IMPLEMENTED_YET
00426 
00432 POCKETSPHINX_EXPORT
00433 int32 ps_lattice_ngram_expand(ps_lattice_t *dag, ngram_model_t *lm);
00434 #endif
00435 
00442 POCKETSPHINX_EXPORT
00443 int ps_lattice_n_frames(ps_lattice_t *dag);
00444 
00445 #endif /* __PS_LATTICE_H__ */