• Main Page
  • Related Pages
  • Data Structures
  • Files
  • File List
  • Globals

src/libpocketsphinx/acmod.h

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
00002 /* ====================================================================
00003  * Copyright (c) 2008 Carnegie Mellon University.  All rights
00004  * reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer. 
00012  *
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in
00015  *    the documentation and/or other materials provided with the
00016  *    distribution.
00017  *
00018  * This work was supported in part by funding from the Defense Advanced 
00019  * Research Projects Agency and the National Science Foundation of the 
00020  * United States of America, and the CMU Sphinx Speech Consortium.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 
00023  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
00024  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00025  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
00026  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00027  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
00028  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
00029  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
00030  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00031  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00032  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  * ====================================================================
00035  *
00036  */
00037 
00043 #ifndef __ACMOD_H__
00044 #define __ACMOD_H__
00045 
00046 /* System headers. */
00047 #include <stdio.h>
00048 
00049 /* SphinxBase headers. */
00050 #include <cmd_ln.h>
00051 #include <logmath.h>
00052 #include <fe.h>
00053 #include <feat.h>
00054 #include <bitvec.h>
00055 
00056 /* Local headers. */
00057 #include "bin_mdef.h"
00058 #include "s2_semi_mgau.h"
00059 #include "ms_mgau.h"
00060 #include "tmat.h"
00061 #include "hmm.h"
00062 
00066 typedef enum acmod_state_e {
00067     ACMOD_IDLE,         
00068     ACMOD_STARTED,      
00069     ACMOD_PROCESSING,   
00070     ACMOD_ENDED         
00071 } acmod_state_t;
00072 
00076 typedef int (*frame_eval_t)(void *eval_obj,
00077                             int16 *senscr,
00078                             int32 *senone_active,
00079                             int32 n_senone_active,
00080                             mfcc_t ** feat,
00081                             int32 frame,
00082                             int32 compallsen,
00083                             int32 *out_bestidx);
00084 
00102 struct acmod_s {
00103     /* Global objects, not retained. */
00104     cmd_ln_t *config;          
00105     logmath_t *lmath;          
00106     glist_t strings;           
00108     /* Feature computation: */
00109     fe_t *fe;                  
00110     feat_t *fcb;               
00112     /* Model parameters: */
00113     bin_mdef_t *mdef;          
00114     tmat_t *tmat;              
00115     void *mgau;                
00118     void (*mgau_free)(void *); 
00120     /* Senone scoring: */
00121     frame_eval_t frame_eval;   
00122     int16 *senone_scores;      
00123     bitvec_t *senone_active_vec; 
00124     int *senone_active;        
00125     int n_senone_active;       
00126     int log_zero;              
00128     /* Utterance processing: */
00129     mfcc_t **mfc_buf;   
00130     mfcc_t ***feat_buf; 
00131     FILE *rawfh;        
00132     FILE *mfcfh;        
00134     /* A whole bunch of flags and counters: */
00135     uint8 state;        
00136     uint8 compallsen;   
00137     uint8 grow_feat;    
00138     uint8 reserved;
00139     int16 output_frame; 
00140     int16 n_mfc_alloc;  
00141     int16 n_mfc_frame;  
00142     int16 mfc_outidx;   
00143     int16 n_feat_alloc; 
00144     int16 n_feat_frame; 
00145     int16 feat_outidx;  
00146 };
00147 typedef struct acmod_s acmod_t;
00148 
00165 acmod_t *acmod_init(cmd_ln_t *config, logmath_t *lmath, fe_t *fe, feat_t *fcb);
00166 
00174 int acmod_set_mfcfh(acmod_t *acmod, FILE *logfh);
00175 
00183 int acmod_set_rawfh(acmod_t *acmod, FILE *logfh);
00184 
00188 void acmod_free(acmod_t *acmod);
00189 
00193 int acmod_start_utt(acmod_t *acmod);
00194 
00198 int acmod_end_utt(acmod_t *acmod);
00199 
00212 int acmod_rewind(acmod_t *acmod);
00213 
00222 int acmod_set_grow(acmod_t *acmod, int grow_feat);
00223 
00235 int acmod_process_raw(acmod_t *acmod,
00236                       int16 const **inout_raw,
00237                       size_t *inout_n_samps,
00238                       int full_utt);
00239 
00251 int acmod_process_cep(acmod_t *acmod,
00252                       mfcc_t ***inout_cep,
00253                       int *inout_n_frames,
00254                       int full_utt);
00255 
00269 int acmod_process_feat(acmod_t *acmod,
00270                        mfcc_t **feat);
00271 
00275 int acmod_frame_idx(acmod_t *acmod);
00276 
00288 int16 const *acmod_score(acmod_t *acmod,
00289                          int *out_frame_idx,
00290                          int16 *out_best_score,
00291                          int32 *out_best_senid);
00292 
00296 void acmod_clear_active(acmod_t *acmod);
00297 
00301 void acmod_activate_hmm(acmod_t *acmod, hmm_t *hmm);
00302 
00309 int const *acmod_active_list(acmod_t *acmod, int *out_n_active);
00310 
00311 #endif /* __ACMOD_H__ */

Generated on Thu Jan 27 2011 for PocketSphinx by  doxygen 1.7.1