42 #ifndef __NGRAM_SEARCH_H__
43 #define __NGRAM_SEARCH_H__
46 #include <sphinxbase/cmd_ln.h>
47 #include <sphinxbase/logmath.h>
48 #include <sphinxbase/ngram_model.h>
49 #include <sphinxbase/listelem_alloc.h>
50 #include <sphinxbase/err.h>
157 #define CAND_SF_ALLOCSIZE 32
182 int32 n_root_chan_eval;
183 int32 n_nonroot_chan_eval;
184 int32 n_last_chan_eval;
185 int32 n_word_lastchan_eval;
186 int32 n_lastphn_cand_utt;
187 int32 n_fwdflat_chan;
188 int32 n_fwdflat_words;
189 int32 n_fwdflat_word_transition;
190 int32 n_senone_active_utt;
294 int32 n_lastphn_cand;
305 int32 bscore_stack_size;
318 bitvec_t *expand_word_flag;
319 int32 *expand_word_list;
320 int32 n_expand_words;
323 float32 fwdflat_fwdtree_lw_ratio;
332 float32 bestpath_fwdtree_lw_ratio;
338 ptmr_t bestpath_perf;
386 int32 score, int32 path, int32 rc);
hmm_t hmm
Basic HMM structure.
Internal implementation of PocketSphinx decoder.
int32 n_frame_alloc
Number of frames allocated in bp_table_idx and friends.
struct chan_s chan_t
Lexical tree node data type.
int ngram_search_find_exit(ngram_search_t *ngs, int frame_idx, int32 *out_best_score, int32 *out_is_final)
Find the best word exit for the current frame in the backpointer table.
Base structure for search module.
ps_lattice_t * ngram_search_lattice(ps_search_t *search)
Construct a word lattice from the current hypothesis.
int32 n_nonroot_chan
Number of valid non-root channels.
void ngram_search_set_lm(ngram_model_t *lm)
Sets the global language model.
chan_t * next
first descendant of this channel
listelem_alloc_t * chan_alloc
For chan_t.
An individual HMM among the HMM search space.
frame_idx_t frame
start or end frame
struct root_chan_s root_chan_t
Lexical tree node data type for the first phone (root) of each dynamic HMM tree structure.
hmm_context_t * hmmctx
HMM context.
int32 n_active_chan[2]
Number entries in active_chan_list.
int16 last2_phone
next-to-last phone of this word
void ngram_search_free_all_rc(ngram_search_t *ngs, int32 w)
Allocate last phone channels for all possible right contexts for word w.
bitvec_t * word_active
array of active flags for all words.
struct bptbl_seg_s bptbl_seg_t
Segmentation "iterator" for backpointer table results.
void ngram_search_save_bp(ngram_search_t *ngs, int frame_idx, int32 w, int32 score, int32 path, int32 rc)
Enter a word in the backpointer table.
void ngram_search_alloc_all_rc(ngram_search_t *ngs, int32 w)
Allocate last phone channels for all possible right contexts for word w.
Implementation of HMM base structure.
int16 ciphone
first ciphone of this node; all words rooted at this node begin with this ciphone ...
int32 ** active_word_list
Array of active multi-phone words for current and next frame.
struct chan_s * next
first descendant of this channel; or, in the case of the last phone of a word, the next alternative r...
Various statistics for profiling.
int32 * single_phone_wid
list of single-phone word ids
int32 n_root_chan_alloc
Number of root_chan allocated.
int16 ci2phone
second ciphone of this node; one root HMM for each unique right context
int32 penult_phn_wid
list of words whose last phone follows this one; this field indicates the first of the list; the rest...
int32 n_active_word[2]
Number entries in active_word_list.
int32 rc_id
right-context id for last phone of words
N-Gram search module structure.
int ngram_search_mark_bptable(ngram_search_t *ngs, int frame_idx)
Record the current frame's index in the backpointer table.
int32 max_nonroot_chan
Maximum possible number of non-root channels.
int32 last_phone_best_score
Best Viterbi path score for last phone.
int32 real_wid
wid of this or latest predecessor real word
root_chan_t * rhmm_1ph
Root HMMs for single-phone words.
void ngram_search_free(ps_search_t *ngs)
Finalize the N-Gram search module.
int32 prev_real_wid
wid of second-last real word
listelem_alloc_t * latnode_alloc
For latnode_t.
Shared information between a set of HMMs.
Segmentation "iterator" for backpointer table results.
uint8 refcnt
Reference count (number of successors)
ps_latnode_t ** frm_wordlist
List of active words in each frame.
Lexical tree node data type for the first phone (root) of each dynamic HMM tree structure.
Lexical tree node data type.
hmm_t hmm
Basic HMM structure.
int32 this_phn_wid
list of words consisting of this single phone; actually the first of the list, like penult_phn_wid; -...
char const * ngram_search_bp_hyp(ngram_search_t *ngs, int bpidx)
Backtrace from a given backpointer index to obtain a word hypothesis.
int16 cur
Current position in bpidx.
chan_t *** active_chan_list
Array of active channels for current and next frame.
a structure for a dictionary.
struct chan_s * alt
sibling; i.e., next descendant of parent HMM
Word graph structure used in bestpath/nbest search.
struct bptbl_s bptbl_t
Back pointer table (forward pass lattice; actually a tree)
int16 n_bpidx
Number of backpointer IDs.
int32 best_score
Best Viterbi path score.
Back pointer table (forward pass lattice; actually a tree)
int32 n_1ph_LMwords
Number single phone dict words also in LM; these come first in single_phone_wid.
void ngram_compute_seg_scores(ngram_search_t *ngs, float32 lwf)
Compute language and acoustic scores for backpointer table entries.
root_chan_t * root_chan
Search structure of HMM instances.
ps_search_t * ngram_search_init(const char *name, ngram_model_t *lm, cmd_ln_t *config, acmod_t *acmod, dict_t *dict, dict2pid_t *d2p)
Initialize the N-Gram search module.
int32 ngram_search_exit_score(ngram_search_t *ngs, bptbl_t *pbe, int rcphone)
Get the exit score for a backpointer entry with a given right context.
int32 s_idx
Start of BScoreStack for various right contexts.
int32 frame_idx_t
Type for frame index values.
int32 n_frame
Number of frames actually present.
ngram_model_t * lmset
Set of language models.
uint8 valid
For absolute pruning.
int32 n_1ph_words
Number single phone words in dict (total)
listelem_alloc_t * root_chan_alloc
For root_chan_t.
int32 ciphone
ciphone for this node
int32 * bpidx
Sequence of backpointer IDs.
ngram_search_stats_t st
Various statistics for profiling.
chan_t ** word_chan
Channels associated with a given word (only used for right contexts, single-phone words in fwdtree se...
int32 * fwdflat_wordlist
List of active word IDs for utterance.
int32 score
Score (best among all right contexts)
int32 n_root_chan
Number of valid root_chan.
Base structure for hypothesis segmentation iterator.
int32 * homophone_set
Each node in the HMM tree structure may point to a set of words whose last phone would follow that no...
ps_seg_t base
Base structure.
float32 ascale
Acoustic score scale for posterior probabilities.
Acoustic model structure.
Building composite triphone (as well as word internal triphones) with the dictionary.
struct ngram_search_stats_s ngram_search_stats_t
Various statistics for profiling.
int16 last_phone
last phone of this word