PocketSphinx  0.6
fsg_search_internal.h
1 /* -*- c-basic-offset:4; indent-tabs-mode: nil -*- */
2 /* ====================================================================
3  * Copyright (c) 1999-2004 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  *
19  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
20  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
23  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  * ====================================================================
32  *
33  */
34 
35 /*
36  * fsg_search_internal.h -- Search structures for FSG decoding.
37  */
38 
39 
40 #ifndef __S2_FSG_SEARCH_H__
41 #define __S2_FSG_SEARCH_H__
42 
43 
44 /* SphinxBase headers. */
45 #include <sphinxbase/glist.h>
46 #include <sphinxbase/cmd_ln.h>
47 #include <sphinxbase/fsg_model.h>
48 
49 /* Local headers. */
50 #include "pocketsphinx_internal.h"
51 #include "hmm.h"
52 #include "fsg_history.h"
53 #include "fsg_lextree.h"
54 
58 typedef struct fsg_seg_s {
61  int16 n_hist;
62  int16 cur;
63 } fsg_seg_t;
64 
68 typedef struct fsg_search_s {
69  ps_search_t base;
70 
73  hash_table_t *fsgs;
74  fsg_model_t *fsg;
77  jsgf_t *jsgf;
82  glist_t pnode_active;
85  int32 beam_orig;
86  int32 pbeam_orig;
87  int32 wbeam_orig;
88  float32 beam_factor;
91  int32 beam, pbeam, wbeam;
92  int32 lw, pip, wip;
95  uint8 final;
96  uint8 bestpath;
98  float32 ascale;
100  int32 bestscore;
101  int32 bpidx_start;
103  int32 ascr, lscr;
105  int32 n_hmm_eval;
106  int32 n_sen_eval;
107 } fsg_search_t;
108 
109 /* Access macros */
110 #define fsg_search_frame(s) ((s)->frame)
111 
115 ps_search_t *fsg_search_init(cmd_ln_t *config,
116  acmod_t *acmod,
117  dict_t *dict,
118  dict2pid_t *d2p);
119 
123 void fsg_search_free(ps_search_t *search);
124 
128 int fsg_search_reinit(ps_search_t *fsgs, dict_t *dict, dict2pid_t *d2p);
129 
134 int fsg_search_start(ps_search_t *search);
135 
139 int fsg_search_step(ps_search_t *search, int frame_idx);
140 
144 int fsg_search_finish(ps_search_t *search);
145 
149 char const *fsg_search_hyp(ps_search_t *search, int32 *out_score, int32 *out_is_final);
150 
151 #endif
glist_t pnode_active_next
Those activated for the next frame.
Implementation of FSG search (and &quot;FSG set&quot;) structure.
Internal implementation of PocketSphinx decoder.
Base structure for search module.
int16 cur
Current position in hist.
Definition: fsg_history.h:95
fsg_model_t * fsg
Currently active FSG; NULL if none.
int32 wbeam_orig
Pruning threshold for word exit.
Segmentation &quot;iterator&quot; for FSG history.
ps_seg_t base
Base structure.
float32 beam_factor
Dynamic/adaptive factor (&lt;=1) applied to above beams to determine actual effective beams...
struct fsg_history_s * history
For storing the Viterbi search history.
int32 wbeam
Effective beams after applying beam_factor.
int32 lscr
Total acoustic and lm score for utt.
float32 ascale
Acoustic score scale for posterior probabilities.
jsgf_t * jsgf
Active JSGF grammar file.
int32 n_hmm_eval
Total HMMs evaluated this utt.
int32 wip
Language weights.
hash_table_t * fsgs
Table of all FSGs loaded.
Implementation of HMM base structure.
hmm_context_t * hmmctx
HMM context.
fsg_hist_entry_t ** hist
Sequence of history entries.
int16 frame_idx_t
Type for frame index values.
Definition: hmm.h:68
int32 beam_orig
Global pruning threshold.
Shared information between a set of HMMs.
Collection of lextrees for an FSG.
Definition: fsg_lextree.h:216
int32 pbeam_orig
Pruning threshold for phone transition.
a structure for a dictionary.
Definition: dict.h:79
int32 bestscore
For beam pruning.
int32 bpidx_start
First history entry index this frame.
uint8 bestpath
Whether to run bestpath search and confidence annotation at end.
int32 n_sen_eval
Total senones evaluated this utt.
glist_t pnode_active
Those active in this frame.
int16 n_hist
Number of history entries.
frame_idx_t frame
Current frame.
Base structure for hypothesis segmentation iterator.
struct fsg_lextree_s * lextree
Lextree structure for the currently active FSG.
Acoustic model structure.
Definition: acmod.h:148
Building composite triphone (as well as word internal triphones) with the dictionary.
Definition: dict2pid.h:148