allphone_search.h
/* -*- c-basic-offset:4; indent-tabs-mode: nil -*- */
/* ====================================================================
* Copyright (c) 2014 Carnegie Mellon University. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
* ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
* NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ====================================================================
*
*/
/*
* allphone_search.h -- Search structures for phoneme decoding.
*/
#ifndef __ALLPHONE_SEARCH_H__
#define __ALLPHONE_SEARCH_H__
/* SphinxBase headers. */
#include <sphinxbase/glist.h>
#include <sphinxbase/cmd_ln.h>
#include <sphinxbase/ngram_model.h>
#include <sphinxbase/bitvec.h>
/* Local headers. */
#include "pocketsphinx_internal.h"
#include "blkarray_list.h"
#include "hmm.h"
typedef struct phmm_s {
hmm_t hmm;
s3pid_t pid;
s3cipid_t ci;
bitvec_t *lc;
bitvec_t *rc;
struct phmm_s *next;
struct plink_s *succlist;
} phmm_t;
typedef struct plink_s {
phmm_t *phmm;
struct plink_s *next;
} plink_t;
typedef struct history_s {
phmm_t *phmm;
int32 score;
int32 tscore;
frame_idx_t ef;
int32 hist;
} history_t;
typedef struct phseg_s {
s3cipid_t ci; /* CI-phone id */
frame_idx_t sf, ef; /* Start and end frame for this phone occurrence */
int32 score; /* Acoustic score for this segment of alignment */
int32 tscore; /* Transition ("LM") score for this segment */
} phseg_t;
typedef struct phseg_iter_s {
ps_seg_t base;
glist_t seg;
} phseg_iter_t;
typedef struct allphone_search_s {
ps_search_t base;
hmm_context_t *hmmctx;
ngram_model_t *lm;
int32 ci_only;
phmm_t **ci_phmm;
int32 *ci2lmwid;
int32 beam, pbeam;
int32 lw, inspen;
frame_idx_t frame;
float32 ascale;
int32 n_tot_frame;
int32 n_hmm_eval;
int32 n_sen_eval;
/* Backtrace information */
blkarray_list_t *history;
/* Hypothesis DAG */
glist_t segments;
ptmr_t perf;
} allphone_search_t;
ps_search_t *allphone_search_init(const char *name,
ngram_model_t * lm,
cmd_ln_t * config,
acmod_t * acmod,
dict_t * dict, dict2pid_t * d2p);
void allphone_search_free(ps_search_t * search);
int allphone_search_reinit(ps_search_t * search, dict_t * dict,
dict2pid_t * d2p);
int allphone_search_start(ps_search_t * search);
int allphone_search_step(ps_search_t * search, int frame_idx);
int allphone_search_finish(ps_search_t * search);
char const *allphone_search_hyp(ps_search_t * search, int32 * out_score);
#endif /* __ALLPHONE_SEARCH_H__ */
frame_idx_t
int32 frame_idx_t
Type for frame index values.
Definition: hmm.h:64
allphone_search_s
Implementation of allphone search structure.
Definition: allphone_search.h:110
allphone_search_s::history
blkarray_list_t * history
List of history nodes allocated in each frame.
Definition: allphone_search.h:130
phmm_s::rc
bitvec_t * rc
Set (bit-vector) of right context phones seen for this PHMM.
Definition: allphone_search.h:65
allphone_search_s::ci_only
int32 ci_only
Use context-independent phones for decoding.
Definition: allphone_search.h:115
allphone_search_s::n_sen_eval
int32 n_sen_eval
Total senones evaluated this utt.
Definition: allphone_search.h:127
phmm_s::pid
s3pid_t pid
Phone id (temp.
Definition: allphone_search.h:62
plink_s
List of links from a PHMM node to its successors; one link per successor.
Definition: allphone_search.h:73
pocketsphinx_internal.h
ps_search_s
Base structure for search module.
Definition: pocketsphinx_internal.h:98
ps_seg_s
Base structure for hypothesis segmentation iterator.
Definition: pocketsphinx_internal.h:178
hmm_context_t
Shared information between a set of HMMs.
hmm.h
HMM data structure and operation.
history_s::score
int32 score
Path score for this path.
Definition: allphone_search.h:83
history_s::hist
int32 hist
Previous history entry.
Definition: allphone_search.h:86
phmm_s::next
struct phmm_s * next
Next unique PHMM for same parent basephone.
Definition: allphone_search.h:66
plink_s::phmm
phmm_t * phmm
Successor PHMM node.
Definition: allphone_search.h:74
dict2pid_t
Building composite triphone (as well as word internal triphones) with the dictionary.
Definition: dict2pid.h:84
phmm_s::hmm
hmm_t hmm
Base HMM structure.
Definition: allphone_search.h:61
plink_s::next
struct plink_s * next
Next link for parent PHMM node.
Definition: allphone_search.h:75
allphone_search_s::hmmctx
hmm_context_t * hmmctx
HMM context.
Definition: allphone_search.h:113
history_s::ef
frame_idx_t ef
End frame.
Definition: allphone_search.h:85
allphone_search_s::inspen
int32 inspen
Language weights.
Definition: allphone_search.h:120
s3cipid_t
int16 s3cipid_t
Size definitions for more semantially meaningful units.
Definition: s3types.h:63
history_s
History (paths) information at any point in allphone Viterbi search.
Definition: allphone_search.h:81
allphone_search_s::n_hmm_eval
int32 n_hmm_eval
Total HMMs evaluated this utt.
Definition: allphone_search.h:126
phmm_s::ci
s3cipid_t ci
Parent basephone for this PHMM.
Definition: allphone_search.h:63
blkarray_list_s
Definition: blkarray_list.h:79
history_s::tscore
int32 tscore
Transition score for this path.
Definition: allphone_search.h:84
hmm_t
An individual HMM among the HMM search space.
allphone_search_s::ci2lmwid
int32 * ci2lmwid
Mapping of CI phones to LM word IDs.
Definition: allphone_search.h:117
phseg_iter_s
Segment iterator over list of phseg.
Definition: allphone_search.h:102
allphone_search_s::ascale
float32 ascale
Acoustic score scale for posterior probabilities.
Definition: allphone_search.h:123
phmm_s::lc
bitvec_t * lc
Set (bit-vector) of left context phones seen for this PHMM.
Definition: allphone_search.h:64
allphone_search_s::lm
ngram_model_t * lm
Ngram model set.
Definition: allphone_search.h:114
dict_t
a structure for a dictionary.
Definition: dict.h:76
allphone_search_s::perf
ptmr_t perf
Performance counter.
Definition: allphone_search.h:134
allphone_search_s::ci_phmm
phmm_t ** ci_phmm
PHMM lists (for each CI phone)
Definition: allphone_search.h:116
phmm_s::succlist
struct plink_s * succlist
List of predecessor PHMM nodes.
Definition: allphone_search.h:67
acmod_s
Acoustic model structure.
Definition: acmod.h:148
phseg_s
Phone level segmentation information.
Definition: allphone_search.h:92
history_s::phmm
phmm_t * phmm
PHMM ending this path.
Definition: allphone_search.h:82
allphone_search_s::pbeam
int32 pbeam
Effective beams after applying beam_factor.
Definition: allphone_search.h:119
allphone_search_s::frame
frame_idx_t frame
Current frame.
Definition: allphone_search.h:122
allphone_search_s::n_tot_frame
int32 n_tot_frame
Total number of frames processed.
Definition: allphone_search.h:125
phmm_s
Models a single unique <senone-sequence, tmat> pair.
Definition: allphone_search.h:60