PocketSphinx  5prealpha
allphone_search.h
1 /* -*- c-basic-offset:4; indent-tabs-mode: nil -*- */
2 /* ====================================================================
3  * Copyright (c) 2014 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  * allphone_search.h -- Search structures for phoneme decoding.
37  */
38 
39 
40 #ifndef __ALLPHONE_SEARCH_H__
41 #define __ALLPHONE_SEARCH_H__
42 
43 
44 /* SphinxBase headers. */
45 #include <sphinxbase/glist.h>
46 #include <sphinxbase/cmd_ln.h>
47 #include <sphinxbase/ngram_model.h>
48 #include <sphinxbase/bitvec.h>
49 
50 /* Local headers. */
51 #include "pocketsphinx_internal.h"
52 #include "blkarray_list.h"
53 #include "hmm.h"
54 
60 typedef struct phmm_s {
62  s3pid_t pid;
64  bitvec_t *lc;
65  bitvec_t *rc;
66  struct phmm_s *next;
67  struct plink_s *succlist;
68 } phmm_t;
69 
73 typedef struct plink_s {
75  struct plink_s *next;
76 } plink_t;
77 
81 typedef struct history_s {
83  int32 score;
84  int32 tscore;
86  int32 hist;
87 } history_t;
88 
92 typedef struct phseg_s {
93  s3cipid_t ci; /* CI-phone id */
94  frame_idx_t sf, ef; /* Start and end frame for this phone occurrence */
95  int32 score; /* Acoustic score for this segment of alignment */
96  int32 tscore; /* Transition ("LM") score for this segment */
97 } phseg_t;
98 
102 typedef struct phseg_iter_s {
103  ps_seg_t base;
104  glist_t seg;
105 } phseg_iter_t;
106 
110 typedef struct allphone_search_s {
111  ps_search_t base;
112 
114  ngram_model_t *lm;
115  int32 ci_only;
117  int32 *ci2lmwid;
119  int32 beam, pbeam;
120  int32 lw, inspen;
123  float32 ascale;
125  int32 n_tot_frame;
126  int32 n_hmm_eval;
127  int32 n_sen_eval;
129  /* Backtrace information */
131  /* Hypothesis DAG */
132  glist_t segments;
133 
134  ptmr_t perf;
137 
141 ps_search_t *allphone_search_init(const char *name,
142  ngram_model_t * lm,
143  cmd_ln_t * config,
144  acmod_t * acmod,
145  dict_t * dict, dict2pid_t * d2p);
146 
150 void allphone_search_free(ps_search_t * search);
151 
155 int allphone_search_reinit(ps_search_t * search, dict_t * dict,
156  dict2pid_t * d2p);
157 
162 int allphone_search_start(ps_search_t * search);
163 
167 int allphone_search_step(ps_search_t * search, int frame_idx);
168 
172 int allphone_search_finish(ps_search_t * search);
173 
177 char const *allphone_search_hyp(ps_search_t * search, int32 * out_score);
178 
179 #endif /* __ALLPHONE_SEARCH_H__ */
Internal implementation of PocketSphinx decoder.
History (paths) information at any point in allphone Viterbi search.
struct phmm_s * next
Next unique PHMM for same parent basephone.
Base structure for search module.
ptmr_t perf
Performance counter.
s3cipid_t ci
Parent basephone for this PHMM.
int32 n_sen_eval
Total senones evaluated this utt.
An individual HMM among the HMM search space.
s3pid_t pid
Phone id (temp.
int32 hist
Previous history entry.
bitvec_t * lc
Set (bit-vector) of left context phones seen for this PHMM.
int32 score
Path score for this path.
Implementation of HMM base structure.
int32 * ci2lmwid
Mapping of CI phones to LM word IDs.
int32 inspen
Language weights.
frame_idx_t ef
End frame.
bitvec_t * rc
Set (bit-vector) of right context phones seen for this PHMM.
Implementation of allphone search structure.
int16 s3cipid_t
Size definitions for more semantially meaningful units.
Definition: s3types.h:63
int32 tscore
Transition score for this path.
Shared information between a set of HMMs.
hmm_context_t * hmmctx
HMM context.
Segment iterator over list of phseg.
a structure for a dictionary.
Definition: dict.h:76
float32 ascale
Acoustic score scale for posterior probabilities.
int32 n_tot_frame
Total number of frames processed.
ngram_model_t * lm
Ngram model set.
hmm_t hmm
Base HMM structure.
int32 ci_only
Use context-independent phones for decoding.
int32 n_hmm_eval
Total HMMs evaluated this utt.
struct plink_s * succlist
List of predecessor PHMM nodes.
int32 frame_idx_t
Type for frame index values.
Definition: hmm.h:64
Models a single unique &lt;senone-sequence, tmat&gt; pair.
phmm_t * phmm
PHMM ending this path.
int32 pbeam
Effective beams after applying beam_factor.
blkarray_list_t * history
List of history nodes allocated in each frame.
Base structure for hypothesis segmentation iterator.
phmm_t ** ci_phmm
PHMM lists (for each CI phone)
Acoustic model structure.
Definition: acmod.h:148
Phone level segmentation information.
Building composite triphone (as well as word internal triphones) with the dictionary.
Definition: dict2pid.h:84
frame_idx_t frame
Current frame.