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. */
52#include "blkarray_list.h"
53#include "hmm.h"
54
60typedef 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
73typedef struct plink_s {
75 struct plink_s *next;
76} plink_t;
77
81typedef struct history_s {
83 int32 score;
84 int32 tscore;
86 int32 hist;
87} history_t;
88
92typedef 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
102typedef struct phseg_iter_s {
103 ps_seg_t base;
104 glist_t seg;
106
110typedef 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;
129 /* Backtrace information */
131 /* Hypothesis DAG */
132 glist_t segments;
133
134 ptmr_t perf;
137
141ps_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
150void allphone_search_free(ps_search_t * search);
151
155int allphone_search_reinit(ps_search_t * search, dict_t * dict,
156 dict2pid_t * d2p);
157
162int allphone_search_start(ps_search_t * search);
163
167int allphone_search_step(ps_search_t * search, int frame_idx);
168
172int allphone_search_finish(ps_search_t * search);
173
177char const *allphone_search_hyp(ps_search_t * search, int32 * out_score);
178
179#endif /* __ALLPHONE_SEARCH_H__ */
Implementation of HMM base structure.
int32 frame_idx_t
Type for frame index values.
Definition: hmm.h:64
Internal implementation of PocketSphinx decoder.
int16 s3cipid_t
Size definitions for more semantially meaningful units.
Definition: s3types.h:63
Acoustic model structure.
Definition: acmod.h:148
Implementation of allphone search structure.
int32 n_hmm_eval
Total HMMs evaluated this utt.
phmm_t ** ci_phmm
PHMM lists (for each CI phone)
frame_idx_t frame
Current frame.
int32 n_sen_eval
Total senones evaluated this utt.
blkarray_list_t * history
List of history nodes allocated in each frame.
int32 n_tot_frame
Total number of frames processed.
int32 * ci2lmwid
Mapping of CI phones to LM word IDs.
float32 ascale
Acoustic score scale for posterior probabilities.
hmm_context_t * hmmctx
HMM context.
int32 ci_only
Use context-independent phones for decoding.
ptmr_t perf
Performance counter.
ngram_model_t * lm
Ngram model set.
int32 inspen
Language weights.
int32 pbeam
Effective beams after applying beam_factor.
Building composite triphone (as well as word internal triphones) with the dictionary.
Definition: dict2pid.h:84
a structure for a dictionary.
Definition: dict.h:76
History (paths) information at any point in allphone Viterbi search.
int32 tscore
Transition score for this path.
int32 hist
Previous history entry.
phmm_t * phmm
PHMM ending this path.
frame_idx_t ef
End frame.
int32 score
Path score for this path.
Shared information between a set of HMMs.
An individual HMM among the HMM search space.
Models a single unique <senone-sequence, tmat> pair.
struct plink_s * succlist
List of predecessor PHMM nodes.
struct phmm_s * next
Next unique PHMM for same parent basephone.
hmm_t hmm
Base HMM structure.
bitvec_t * rc
Set (bit-vector) of right context phones seen for this PHMM.
bitvec_t * lc
Set (bit-vector) of left context phones seen for this PHMM.
s3pid_t pid
Phone id (temp.
s3cipid_t ci
Parent basephone for this PHMM.
Segment iterator over list of phseg.
Phone level segmentation information.
Base structure for search module.
Base structure for hypothesis segmentation iterator.