#include <sent/stddefs.h>
#include <sent/htk_hmm.h>
#include <sent/htk_param.h>
Go to the source code of this file.
Data Structures | |
struct | MIXCACHE |
A component of per-codebook probability cache while search. More... | |
struct | HMMWork |
Work area and cache for HMM computation. More... | |
Defines | |
#define | TMBEAMWIDTH 5.0 |
Score beam offset for GPRUNE_SEL_BEAM. | |
Enumerations | |
enum | { GPRUNE_SEL_UNDEF, GPRUNE_SEL_NONE, GPRUNE_SEL_SAFE, GPRUNE_SEL_HEURISTIC, GPRUNE_SEL_BEAM } |
Symbols to specify which Gaussian pruning algorithm to use. More... | |
Functions | |
void | make_log_tbl () |
Generate a value tables of ![]() | |
LOGPROB | addlog (LOGPROB x, LOGPROB y) |
Rapid computation of ![]() | |
LOGPROB | addlog_array (LOGPROB *x, int n) |
Rapid computation of ![]() | |
boolean | outprob_init (HMMWork *wrk, HTK_HMM_INFO *hmminfo, HTK_HMM_INFO *gshmm, int gms_num, int gprune_method, int gprune_mixnum) |
Initialize and setup acoustic computation functions. | |
boolean | outprob_prepare (HMMWork *wrk, int framenum) |
Prepare for the next input of given frame length. | |
void | outprob_free (HMMWork *wrk) |
Free all work area for outprob computation. | |
boolean | outprob_cache_init (HMMWork *wrk) |
Initialize the cache data, should be called once on startup. | |
boolean | outprob_cache_prepare (HMMWork *wrk) |
Prepare cache for the next input, by clearing the existing cache. | |
void | outprob_cache_free (HMMWork *wrk) |
Free work area for cache. | |
LOGPROB | outprob_state (HMMWork *wrk, int t, HTK_HMM_State *stateinfo, HTK_Param *param) |
Compute output probability of a state. | |
void | outprob_cd_nbest_init (HMMWork *wrk, int num) |
Initialize work area for outprob_cd_nbest(). | |
void | outprob_cd_nbest_free (HMMWork *wrk) |
Free work area for outprob_cd_nbest(). | |
LOGPROB | outprob_cd (HMMWork *wrk, int t, CD_State_Set *lset, HTK_Param *param) |
Compute the log output probability of a pseudo state set. | |
boolean | gms_init (HMMWork *wrk) |
Initialize the GMS related functions and data. | |
boolean | gms_prepare (HMMWork *wrk, int framelen) |
Setup GMS parameters for next input. | |
void | gms_free (HMMWork *wrk) |
Free GMS related work areas. | |
LOGPROB | gms_state (HMMWork *wrk) |
Get HMM State probability of current state with Gaussiam Mixture Selection. | |
void | gms_gprune_init (HMMWork *wrk) |
Initialization of GMS HMM likelihood computation. | |
void | gms_gprune_prepare (HMMWork *wrk) |
Prepare GMS HMM computation for the next speech input. | |
void | gms_gprune_free (HMMWork *wrk) |
Free GMS related work area. | |
void | compute_gs_scores (HMMWork *wrk) |
Main function to compute all the GMS HMM states in a frame with the input vectore specified by OP_vec. | |
LOGPROB | calc_mix (HMMWork *wrk) |
Compute the output probability of current state OP_State. | |
boolean | calc_tied_mix_init (HMMWork *wrk) |
Initialize codebook cache area. | |
boolean | calc_tied_mix_prepare (HMMWork *wrk, int framenum) |
Setup codebook cache for the next incoming input. | |
void | calc_tied_mix_free (HMMWork *wrk) |
Free work area for tied-mixture calculation. | |
LOGPROB | calc_tied_mix (HMMWork *wrk) |
Compute the output probability of current state OP_State on tied-mixture model. | |
int | cache_push (HMMWork *wrk, int id, LOGPROB score, int len) |
Store a score to the current list of computed Gaussians. | |
LOGPROB | compute_g_base (HMMWork *wrk, HTK_HMM_Dens *binfo) |
Calculate probability of a Gaussian density against input vector on OP_vec. | |
boolean | gprune_none_init (HMMWork *wrk) |
Initialize and setup work area for Gaussian computation. | |
void | gprune_none_free (HMMWork *wrk) |
Free gprune_none related work area. | |
void | gprune_none (HMMWork *wrk, HTK_HMM_Dens **g, int num, int *last_id) |
Compute a set of Gaussians with no pruning. | |
LOGPROB | compute_g_safe (HMMWork *wrk, HTK_HMM_Dens *binfo, LOGPROB thres) |
Calculate probability with safe pruning. | |
boolean | gprune_safe_init (HMMWork *wrk) |
Initialize and setup work area for Gaussian pruning by safe algorithm. | |
void | gprune_safe_free (HMMWork *wrk) |
Free gprune_safe related work area. | |
void | gprune_safe (HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id) |
Compute a set of Gaussians with safe pruning. | |
boolean | gprune_heu_init (HMMWork *wrk) |
Initialize and setup work area for Gaussian pruning by heuristic algorithm. | |
void | gprune_heu_free (HMMWork *wrk) |
Free gprune_heu related work area. | |
void | gprune_heu (HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id) |
Compute a set of Gaussians with heuristic pruning. | |
boolean | gprune_beam_init (HMMWork *wrk) |
Initialize and setup work area for Gaussian pruning by beam algorithm. | |
void | gprune_beam_free (HMMWork *wrk) |
Free gprune_beam related work area. | |
void | gprune_beam (HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id) |
Compute a set of Gaussians with beam pruning. |
Definition in file hmm_calc.h.
#define TMBEAMWIDTH 5.0 |
Score beam offset for GPRUNE_SEL_BEAM.
Larger value may ease pruning error, but processing may become slower. Smaller value can speed up the acoustic computation, but may cause error.
Definition at line 52 of file hmm_calc.h.
Referenced by set_dimthres().
anonymous enum |
Symbols to specify which Gaussian pruning algorithm to use.
Definition at line 43 of file hmm_calc.h.
void make_log_tbl | ( | ) |
Generate a value tables of .
is from 0 to (- VRANGE), and table size is TBLSIZE.
Definition at line 42 of file addlog.c.
Referenced by outprob_init().
Rapid computation of .
a | [in] array of log values | |
n | [in] length of above |
Definition at line 103 of file addlog.c.
Referenced by calc_mix(), calc_tied_mix(), and gmm_calc_mix().
boolean outprob_init | ( | HMMWork * | wrk, | |
HTK_HMM_INFO * | hmminfo, | |||
HTK_HMM_INFO * | gshmm, | |||
int | gms_num, | |||
int | gprune_method, | |||
int | gprune_mixnum | |||
) |
Initialize and setup acoustic computation functions.
wrk | [i/o] HMM computation work area | |
hmminfo | [in] HMM definition | |
gshmm | [in] GMS HMM definition if exist, or NULL if not | |
gms_num | [in] number of GMS HMM to compute (valid if gshmm != NULL) | |
gprune_method | [in] gaussian pruning method | |
gprune_mixnum | [in] number of pdf to compute at a codebook in gaussian pruning |
select functions
Definition at line 68 of file outprob_init.c.
Referenced by j_final_fusion().
boolean outprob_prepare | ( | HMMWork * | wrk, | |
int | framenum | |||
) |
Prepare for the next input of given frame length.
wrk | [i/o] HMM computation work area | |
framenum | [in] input length in frame. |
Definition at line 166 of file outprob_init.c.
Referenced by get_back_trellis(), RealTimePipeLine(), and reset_mfcc().
void outprob_free | ( | HMMWork * | wrk | ) |
Free all work area for outprob computation.
wrk | [i/o] HMM computation work area |
Definition at line 187 of file outprob_init.c.
Referenced by j_process_am_free().
boolean outprob_cache_init | ( | HMMWork * | wrk | ) |
Initialize the cache data, should be called once on startup.
wrk | [i/o] HMM computation work area |
Definition at line 78 of file outprob.c.
Referenced by outprob_init().
boolean outprob_cache_prepare | ( | HMMWork * | wrk | ) |
Prepare cache for the next input, by clearing the existing cache.
wrk | [i/o] HMM computation work area |
Definition at line 96 of file outprob.c.
Referenced by outprob_prepare().
void outprob_cache_free | ( | HMMWork * | wrk | ) |
Free work area for cache.
wrk | [i/o] HMM computation work area |
Definition at line 158 of file outprob.c.
Referenced by outprob_free().
LOGPROB outprob_state | ( | HMMWork * | wrk, | |
int | t, | |||
HTK_HMM_State * | stateinfo, | |||
HTK_Param * | param | |||
) |
Compute output probability of a state.
Set the needed values to the global variables that begins with "OP_", and call calc_outprob_state(). The calc_outprob_state() is actually a function pointer, and the entity is either calc_tied_mix() for tied-mixture model and calc_mix() for others. (If you use GMS, the entity will be gms_state() instead.)
The state-level cache is also consulted here.
wrk | [i/o] HMM computation work area | |
t | [in] time frame | |
stateinfo | [in] state information to compute the output probability | |
param | [in] input parameter vectors |
Definition at line 184 of file outprob.c.
Referenced by next_word(), outprob(), outprob_cd_avg(), outprob_cd_max(), outprob_cd_nbest(), and start_word().
void outprob_cd_nbest_init | ( | HMMWork * | wrk, | |
int | num | |||
) |
Initialize work area for outprob_cd_nbest().
wrk | [i/o] HMM computation work area | |
num | [in] number of top states to be calculated. |
Definition at line 219 of file outprob.c.
Referenced by outprob_init().
void outprob_cd_nbest_free | ( | HMMWork * | wrk | ) |
Free work area for outprob_cd_nbest().
wrk | [i/o] HMM computation work area |
Definition at line 232 of file outprob.c.
Referenced by outprob_free().
LOGPROB outprob_cd | ( | HMMWork * | wrk, | |
int | t, | |||
CD_State_Set * | lset, | |||
HTK_Param * | param | |||
) |
Compute the log output probability of a pseudo state set.
wrk | [i/o] HMM computation work area | |
t | [in] input frame | |
lset | [in] pseudo state set | |
param | [in] input parameter data |
Definition at line 344 of file outprob.c.
Referenced by next_word(), outprob(), and start_word().
boolean gms_init | ( | HMMWork * | wrk | ) |
Initialize the GMS related functions and data.
wrk | [i/o] HMM computation work area |
Definition at line 283 of file gms.c.
Referenced by outprob_init().
boolean gms_prepare | ( | HMMWork * | wrk, | |
int | framenum | |||
) |
Setup GMS parameters for next input.
wrk | [i/o] HMM computation work area | |
framenum | [in] length of next input in frames |
Definition at line 330 of file gms.c.
Referenced by outprob_prepare().
void gms_free | ( | HMMWork * | wrk | ) |
Free GMS related work areas.
wrk | [i/o] HMM computation work area |
Definition at line 366 of file gms.c.
Referenced by outprob_free().
Get HMM State probability of current state with Gaussiam Mixture Selection.
If the GMS HMM score of the corresponding basephone is below the N-best, the triphone score will not be computed, and the score of the GMS HMM will be returned instead as a fallback score. Else, the precise triphone will be computed and returned.
wrk | [i/o] HMM computation work area |
Definition at line 394 of file gms.c.
Referenced by outprob_init().
void gms_gprune_init | ( | HMMWork * | wrk | ) |
Initialization of GMS HMM likelihood computation.
wrk | [i/o] HMM computation work area |
Definition at line 43 of file gms_gprune.c.
Referenced by gms_init().
void gms_gprune_prepare | ( | HMMWork * | wrk | ) |
Prepare GMS HMM computation for the next speech input.
wrk | [i/o] HMM computation work area |
Definition at line 55 of file gms_gprune.c.
Referenced by gms_prepare().
void gms_gprune_free | ( | HMMWork * | wrk | ) |
Free GMS related work area.
wrk | [i/o] HMM computation work area |
Definition at line 70 of file gms_gprune.c.
Referenced by gms_free().
void compute_gs_scores | ( | HMMWork * | wrk | ) |
Main function to compute all the GMS HMM states in a frame with the input vectore specified by OP_vec.
This function assumes that this will be called for sequencial frame, since it utilizes the result of previous frame for faster pruning.
wrk | [i/o] HMM computation work area |
Definition at line 202 of file gms_gprune.c.
Referenced by do_gms().
Compute the output probability of current state OP_State.
No codebook-level cache is done.
wrk | [i/o] HMM computation work area |
Definition at line 41 of file calc_mix.c.
Referenced by outprob_init().
boolean calc_tied_mix_init | ( | HMMWork * | wrk | ) |
Initialize codebook cache area.
wrk | [i/o] HMM computation work area |
Definition at line 51 of file calc_tied_mix.c.
Referenced by outprob_init().
boolean calc_tied_mix_prepare | ( | HMMWork * | wrk, | |
int | framenum | |||
) |
Setup codebook cache for the next incoming input.
wrk | [i/o] HMM computation work area | |
framenum | [in] length of the next input. |
Definition at line 69 of file calc_tied_mix.c.
Referenced by outprob_prepare().
void calc_tied_mix_free | ( | HMMWork * | wrk | ) |
Free work area for tied-mixture calculation.
wrk | [i/o] HMM computation work area |
Definition at line 133 of file calc_tied_mix.c.
Referenced by outprob_free().
Compute the output probability of current state OP_State on tied-mixture model.
This function assumes that the OP_state is assigned to a tied-mixture codebook. Here the output probability of Gaussian mixture component referred by OP_state is consulted to the book level cache, and if not computed yet on that input frame time, it will be computed here.
wrk | [i/o] HMM computation work area |
Definition at line 154 of file calc_tied_mix.c.
Referenced by outprob_init().
Store a score to the current list of computed Gaussians.
Store the calculated score of a Gaussian to OP_calced_score, with its corresponding mixture id to OP_calced_id.
The OP_calced_score and OP_calced_id always holds the (OP_gprune_num)-best scores and ids. If the number of stored Gaussian from start has reached OP_gprune_num and the given score is below the bottom, it will be dropped. Else, the new score will be inserted and the bottom will be dropped from the list.
The OP_calced_score will always kept sorted by the scores.
wrk | [i/o] HMM computation work area | |
id | [in] mixture id of the Gaussian to store | |
score | [in] score of the Gaussian to store | |
len | [in] current number of stored scores in OP_calced_score |
Definition at line 88 of file gprune_common.c.
Referenced by gprune_beam(), gprune_heu(), and gprune_safe().
LOGPROB compute_g_base | ( | HMMWork * | wrk, | |
HTK_HMM_Dens * | binfo | |||
) |
Calculate probability of a Gaussian density against input vector on OP_vec.
wrk | [i/o] HMM computation work area | |
binfo | [in] a Gaussian density |
Definition at line 59 of file gprune_none.c.
Referenced by gprune_beam(), gprune_heu(), gprune_none(), and gprune_safe().
boolean gprune_none_init | ( | HMMWork * | wrk | ) |
Initialize and setup work area for Gaussian computation.
wrk | [i/o] HMM computation work area |
Definition at line 86 of file gprune_none.c.
Referenced by outprob_init().
void gprune_none_free | ( | HMMWork * | wrk | ) |
Free gprune_none related work area.
wrk | [i/o] HMM computation work area |
Definition at line 104 of file gprune_none.c.
Referenced by outprob_init().
void gprune_none | ( | HMMWork * | wrk, | |
HTK_HMM_Dens ** | g, | |||
int | num, | |||
int * | last_id | |||
) |
Compute a set of Gaussians with no pruning.
The calculated scores will be stored to OP_calced_score, with its corresponding mixture id to OP_calced_id. The number of calculated mixtures is also stored in OP_calced_num.
This can be called from calc_tied_mix() or calc_mix().
wrk | [i/o] HMM computation work area | |
g | [in] set of Gaussian densities to compute the output probability. | |
num | [in] length of above | |
last_id | [in] ID list of N-best mixture in previous input frame, or NULL if not exist |
Definition at line 126 of file gprune_none.c.
Referenced by outprob_init().
LOGPROB compute_g_safe | ( | HMMWork * | wrk, | |
HTK_HMM_Dens * | binfo, | |||
LOGPROB | thres | |||
) |
Calculate probability with safe pruning.
Calculate probability of a Gaussian toward OP_vec, performing pruning using the scholar threshold.
wrk | [i/o] HMM computation work area | |
binfo | [in] Gaussian density | |
thres | [in] threshold |
Definition at line 76 of file gprune_safe.c.
Referenced by gprune_beam(), gprune_heu(), and gprune_safe().
boolean gprune_safe_init | ( | HMMWork * | wrk | ) |
Initialize and setup work area for Gaussian pruning by safe algorithm.
wrk | [i/o] HMM computation work area |
Definition at line 107 of file gprune_safe.c.
Referenced by outprob_init().
void gprune_safe_free | ( | HMMWork * | wrk | ) |
Free gprune_safe related work area.
wrk | [i/o] HMM computation work area |
Definition at line 127 of file gprune_safe.c.
Referenced by outprob_init().
void gprune_safe | ( | HMMWork * | wrk, | |
HTK_HMM_Dens ** | g, | |||
int | gnum, | |||
int * | last_id | |||
) |
Compute a set of Gaussians with safe pruning.
If the N-best mixtures in the previous frame is specified in last_id, They are first computed to set the initial threshold. After that, the rest of the Gaussians will be computed with the thresholds to drop unpromising Gaussians from computation at early stage of likelihood computation. If the computation of a Gaussian reached to the end, the threshold will be updated to always hold the likelihood of current N-best score.
The calculated scores will be stored to OP_calced_score, with its corresponding mixture id to OP_calced_id. These are done by calling cache_push(). The number of calculated mixtures is also stored in OP_calced_num.
This can be called from calc_tied_mix() or calc_mix().
wrk | [i/o] HMM computation work area | |
g | [in] set of Gaussian densities to compute the output probability | |
gnum | [in] length of above | |
last_id | [in] ID list of N-best mixture in previous input frame, or NULL if not exist |
Definition at line 159 of file gprune_safe.c.
Referenced by outprob_init().
boolean gprune_heu_init | ( | HMMWork * | wrk | ) |
Initialize and setup work area for Gaussian pruning by heuristic algorithm.
wrk | [i/o] HMM computation work area |
Definition at line 237 of file gprune_heu.c.
Referenced by outprob_init().
void gprune_heu_free | ( | HMMWork * | wrk | ) |
Free gprune_heu related work area.
wrk | [i/o] HMM computation work area |
Definition at line 259 of file gprune_heu.c.
Referenced by outprob_init().
void gprune_heu | ( | HMMWork * | wrk, | |
HTK_HMM_Dens ** | g, | |||
int | gnum, | |||
int * | last_id | |||
) |
Compute a set of Gaussians with heuristic pruning.
If the N-best mixtures in the previous frame is specified in last_id, They are first computed to get the maximum value for each dimension. After that, the rest of the Gaussians will be computed using the maximum values as heuristics of uncomputed dimensions to drop unpromising Gaussians from computation at early stage of likelihood computation. If the last_id is not specified (typically at the first frame of the input), a safe pruning as same as one in gprune_safe.c will be applied.
The calculated scores will be stored to OP_calced_score, with its corresponding mixture id to OP_calced_id. These are done by calling cache_push(). The number of calculated mixtures is also stored in OP_calced_num.
This can be called from calc_tied_mix() or calc_mix().
wrk | [i/o] HMM computation work area | |
g | [in] set of Gaussian densities to compute the output probability | |
gnum | [in] length of above | |
last_id | [in] ID list of N-best mixture in previous input frame, or NULL if not exist |
Definition at line 293 of file gprune_heu.c.
Referenced by outprob_init().
boolean gprune_beam_init | ( | HMMWork * | wrk | ) |
Initialize and setup work area for Gaussian pruning by beam algorithm.
wrk | [i/o] HMM computation work area |
Definition at line 234 of file gprune_beam.c.
Referenced by outprob_init().
void gprune_beam_free | ( | HMMWork * | wrk | ) |
Free gprune_beam related work area.
wrk | [i/o] HMM computation work area |
Definition at line 256 of file gprune_beam.c.
Referenced by outprob_init().
void gprune_beam | ( | HMMWork * | wrk, | |
HTK_HMM_Dens ** | g, | |||
int | gnum, | |||
int * | last_id | |||
) |
Compute a set of Gaussians with beam pruning.
If the N-best mixtures in the previous frame is specified in last_id, They are first computed to set the thresholds for each dimension. After that, the rest of the Gaussians will be computed with those dimension thresholds to drop unpromising Gaussians from computation at early stage of likelihood computation. If the last_id is not specified (typically at the first frame of the input), a safe pruning as same as one in gprune_safe.c will be applied.
The calculated scores will be stored to OP_calced_score, with its corresponding mixture id to OP_calced_id. These are done by calling cache_push(). The number of calculated mixtures is also stored in OP_calced_num.
This can be called from calc_tied_mix() or calc_mix().
wrk | [i/o] HMM computation work area | |
g | [in] set of Gaussian densities to compute the output probability | |
gnum | [in] length of above | |
last_id | [in] ID list of N-best mixture in previous input frame, or NULL if not exist |
Definition at line 289 of file gprune_beam.c.
Referenced by outprob_init().