hmm.h
上传用户:pch5521
上传日期:2017-02-05
资源大小:1258k
文件大小:5k
源码类别:

网络

开发平台:

Unix_Linux

  1. /**
  2.  * @file   hmm.h
  3.  * @author Akinobu LEE
  4.  * @date   Thu Feb 10 14:54:06 2005
  5.  *
  6.  * <EN>
  7.  * @brief  Hidden Marcov Model for recognition.
  8.  *
  9.  * This file defines %HMM instance structure for recognition.
  10.  * When recognition, the required word %HMM or tree lexicon will be built
  11.  * using these structures referencing word dictionary and HTK %HMM Acoustic
  12.  * Model (defined in htk_hmm.h), and actual likelihood computation.
  13.  * </EN>
  14.  * <JA>
  15.  * @brief  千急纷换脱の Hidden Marcov Model
  16.  *
  17.  * このファイルでは, 千急における%HMMの菇陇挛を年盗していますˉ
  18.  * 千急箕には, 辑今および不读モデル菇陇挛 (htk_hmm.h) を傅に
  19.  * 涩妥な帽胳%HMMや腾菇陇步辑今がこの菇陇挛を脱いて菇蜜され,
  20.  * 不读锑刨纷换はこの惧で乖われますˉ
  21.  * </JA>
  22.  *
  23.  * $Revision: 1.4 $
  24.  *
  25.  */
  26. /*
  27.  * Copyright (c) 1991-2006 Kawahara Lab., Kyoto University
  28.  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
  29.  * Copyright (c) 2005-2006 Julius project team, Nagoya Institute of Technology
  30.  * All rights reserved
  31.  */
  32. #ifndef __SENT_HMM_NEW2_H__
  33. #define __SENT_HMM_NEW2_H__
  34. #include <sent/stddefs.h>
  35. #include <sent/htk_hmm.h>
  36. #include <sent/htk_param.h>
  37. /// Transition arc of %HMM state
  38. typedef struct _a_cell {
  39.   LOGPROB a; ///< Transition probability in log10
  40.   int arc; ///< Transition destination in state ID
  41.   struct _a_cell *next;  ///< Pointer to next transition on the same state
  42. } A_CELL;
  43. /// %HMM State
  44. typedef struct {
  45.   A_CELL *ac; ///< List of transition arcs from this state
  46.   /**
  47.    * @brief Pointer to corresponding output state definition
  48.    *
  49.    * When a triphone model is used, if this state is located as a
  50.    * part of phoneme %HMM on @em word-edge, the corresponding
  51.    * @em pseudo-triphone, i.e. "*-e+g", "k-a+*", should be assigned.
  52.    * Otherwise, i.e. if this state is located at @em internal position
  53.    * of a word, pointer to the corresponding @em physical
  54.    * (actually defined) %HMM will be assigned.
  55.    * When a triphone model is used, phoneme %HMMs on @em word-edge should
  56.    * be @em pseudo-triphone, i.e. "*-e+g", "k-a+*".  In this case,  the
  57.    * belonging state should hold the output probability function
  58.    * in CD_State_Set.
  59.    * Otherwise, i.e. if this state is located at @em internal position
  60.    * of a word, pointer to the corresponding @em physical
  61.    * (actually defined) %HMM will be assigned.
  62.    */
  63.   union {
  64.     HTK_HMM_State *state; ///< Pointer to the mapped physical %HMM
  65.     CD_State_Set  *cdset; ///< Pointer to the pseudo %HMM
  66.   } out;
  67.   boolean is_pseudo_state; ///< TRUE if pseudo %HMM is assigned, FALSE if physical %HMM is assigned
  68. } HMM_STATE;
  69. /**
  70.  * @brief %HMM state sequence
  71.  *
  72.  * @note This assumes that there is only one transition that goes outside
  73.  * this %HMM state sequence.
  74.  */
  75. typedef struct {
  76.   int len; ///< Length of state
  77.   HMM_STATE *state; ///< Array of state
  78. #ifndef MULTIPATH_VERSION
  79.   LOGPROB accept_ac_a; ///< Transition probability outside this sequence (fixed to one)
  80. #endif
  81. } HMM;
  82. /**
  83.  * Token definition for viterbi segmentation.
  84.  * 
  85.  */
  86. typedef struct _seg_token {
  87.   int last_id; ///< ID of last unit
  88.   int last_end_frame; ///< Frame at which the last unit ends
  89.   LOGPROB last_end_score; ///< Score at which the last unit ends
  90.   struct _seg_token *next; ///< Pointer to previous token context, NULL if no context
  91.   struct _seg_token *list; ///< Link to next token, NULL if last
  92. } SEGTOKEN;
  93. /* mkwhmm.c */
  94. HMM *new_make_word_hmm(HTK_HMM_INFO *, HMM_Logical  **, int
  95. #ifdef MULTIPATH_VERSION
  96.        , boolean *
  97. #endif
  98.        );
  99. HMM *new_make_word_hmm_with_lm(HTK_HMM_INFO *, HMM_Logical  **, int
  100. #ifdef MULTIPATH_VERSION
  101.        , boolean *
  102. #endif
  103.        , LOGPROB *);
  104. void free_hmm(HMM *);
  105. /* vsegment.c */
  106. LOGPROB viterbi_segment(HMM *hmm, HTK_Param *param, int *endstates, int ulen, int **id_ret, int **seg_ret, LOGPROB **uscore_ret, int *retlen);
  107. /* addlog.c */
  108. void make_log_tbl();
  109. LOGPROB addlog(LOGPROB x, LOGPROB y);
  110. LOGPROB addlog_array(LOGPROB *x, int n);
  111. /* outprob_init.c */
  112. boolean
  113. outprob_init(HTK_HMM_INFO *hmminfo,
  114.      HTK_HMM_INFO *gshmm, int gms_num,
  115.      int gprune_method, int gprune_mixnum
  116.      );
  117. boolean outprob_prepare(int framenum);
  118. void outprob_free();
  119. /* outprob.c */
  120. boolean outprob_cache_init();
  121. boolean outprob_cache_prepare();
  122. void outprob_cache_free();
  123. LOGPROB outprob_state(int t, HTK_HMM_State *stateinfo, HTK_Param *param);
  124. void outprob_cd_nbest_init(int num);
  125. void outprob_cd_nbest_free();
  126. LOGPROB outprob_cd(int t, CD_State_Set *lset, HTK_Param *param);
  127. LOGPROB outprob(int t, HMM_STATE *hmmstate, HTK_Param *param);
  128. /* gms.c */
  129. boolean gms_init(int nbest);
  130. boolean gms_prepare(int framelen);
  131. void gms_free();
  132. LOGPROB gms_state();
  133. /* gms_gprune.c */
  134. void gms_gprune_init(HTK_HMM_INFO *hmminfo, int gsset_num);
  135. void gms_gprune_prepare();
  136. void gms_gprune_free();
  137. void compute_gs_scores(GS_SET *gsset, int gsset_num, LOGPROB *scores_ret);
  138. /* calc_mix.c */
  139. LOGPROB calc_mix();
  140. /* calc_tied_mix.c */
  141. boolean calc_tied_mix_init();
  142. boolean calc_tied_mix_prepare(int framenum);
  143. void calc_tied_mix_free();
  144. LOGPROB calc_tied_mix();
  145. /* hmminfo/put_htkdata_info */
  146. void put_hmm_arc(HMM *d);
  147. void put_hmm_outprob(HMM *d);
  148. void put_hmm(HMM *d);
  149. #endif /* __SENT_HMM_NEW2_H__ */