Acoustic model structures for PocketSphinx. More...
#include <stdio.h>
#include <cmd_ln.h>
#include <logmath.h>
#include <fe.h>
#include <feat.h>
#include <bitvec.h>
#include "bin_mdef.h"
#include "s2_semi_mgau.h"
#include "ms_mgau.h"
#include "tmat.h"
#include "hmm.h"
Go to the source code of this file.
Data Structures | |
struct | acmod_s |
Acoustic model structure. More... | |
Typedefs | |
typedef enum acmod_state_e | acmod_state_t |
States in utterance processing. | |
typedef int(* | frame_eval_t )(void *eval_obj, int16 *senscr, int32 *senone_active, int32 n_senone_active, mfcc_t **feat, int32 frame, int32 compallsen, int32 *out_bestidx) |
Function which computes one frame of GMM scores. | |
typedef struct acmod_s | acmod_t |
Enumerations | |
enum | acmod_state_e { ACMOD_IDLE, ACMOD_STARTED, ACMOD_PROCESSING, ACMOD_ENDED } |
States in utterance processing. More... | |
Functions | |
acmod_t * | acmod_init (cmd_ln_t *config, logmath_t *lmath, fe_t *fe, feat_t *fcb) |
Initialize an acoustic model. | |
int | acmod_set_mfcfh (acmod_t *acmod, FILE *logfh) |
Start logging MFCCs to a filehandle. | |
int | acmod_set_rawfh (acmod_t *acmod, FILE *logfh) |
Start logging raw audio to a filehandle. | |
void | acmod_free (acmod_t *acmod) |
Finalize an acoustic model. | |
int | acmod_start_utt (acmod_t *acmod) |
Mark the start of an utterance. | |
int | acmod_end_utt (acmod_t *acmod) |
Mark the end of an utterance. | |
int | acmod_rewind (acmod_t *acmod) |
Rewind the current utterance, allowing it to be rescored. | |
int | acmod_set_grow (acmod_t *acmod, int grow_feat) |
Set memory allocation policy for utterance processing. | |
int | acmod_process_raw (acmod_t *acmod, int16 const **inout_raw, size_t *inout_n_samps, int full_utt) |
Feed raw audio data to the acoustic model for scoring. | |
int | acmod_process_cep (acmod_t *acmod, mfcc_t ***inout_cep, int *inout_n_frames, int full_utt) |
Feed acoustic feature data into the acoustic model for scoring. | |
int | acmod_process_feat (acmod_t *acmod, mfcc_t **feat) |
Feed dynamic feature data into the acoustic model for scoring. | |
int | acmod_frame_idx (acmod_t *acmod) |
Get the current frame index. | |
int16 const * | acmod_score (acmod_t *acmod, int *out_frame_idx, int16 *out_best_score, int32 *out_best_senid) |
Score one frame of data. | |
void | acmod_clear_active (acmod_t *acmod) |
Clear set of active senones. | |
void | acmod_activate_hmm (acmod_t *acmod, hmm_t *hmm) |
Activate senones associated with an HMM. | |
int const * | acmod_active_list (acmod_t *acmod, int *out_n_active) |
Return the array of active senones. |
Acoustic model structures for PocketSphinx.
Definition in file acmod.h.
enum acmod_state_e |
int const* acmod_active_list | ( | acmod_t * | acmod, | |
int * | out_n_active | |||
) |
Return the array of active senones.
out_n_active | Output: number of elements in returned array. |
acmod_t* acmod_init | ( | cmd_ln_t * | config, | |
logmath_t * | lmath, | |||
fe_t * | fe, | |||
feat_t * | fcb | |||
) |
Initialize an acoustic model.
config | a command-line object containing parameters. This pointer is not retained by this object. | |
lmath | global log-math parameters. | |
fe | a previously-initialized acoustic feature module to use, or NULL to create one automatically. If this is supplied and its parameters do not match those in the acoustic model, this function will fail. This pointer is not retained. | |
fe | a previously-initialized dynamic feature module to use, or NULL to create one automatically. If this is supplied and its parameters do not match those in the acoustic model, this function will fail. This pointer is not retained. |
Definition at line 221 of file acmod.c.
References acmod_free(), ACMOD_IDLE, acmod_s::compallsen, acmod_s::config, acmod_s::fcb, acmod_s::fe, acmod_s::feat_buf, acmod_s::lmath, acmod_s::log_zero, acmod_s::mdef, acmod_s::mfc_buf, acmod_s::n_feat_alloc, acmod_s::n_mfc_alloc, acmod_s::senone_active, acmod_s::senone_active_vec, acmod_s::senone_scores, and acmod_s::state.
Referenced by ps_reinit().
int acmod_process_cep | ( | acmod_t * | acmod, | |
mfcc_t *** | inout_cep, | |||
int * | inout_n_frames, | |||
int | full_utt | |||
) |
Feed acoustic feature data into the acoustic model for scoring.
inout_cep | In: Pointer to buffer of features Out: Pointer to next frame to be read | |
inout_n_frames | In: Number of frames available Out: Number of frames remaining | |
full_utt | If non-zero, this block represents a full utterance and should be processed as such. |
Definition at line 595 of file acmod.c.
References ACMOD_ENDED, ACMOD_PROCESSING, ACMOD_STARTED, acmod_s::fcb, acmod_s::feat_buf, acmod_s::feat_outidx, acmod_s::grow_feat, acmod_s::mfcfh, acmod_s::n_feat_alloc, acmod_s::n_feat_frame, and acmod_s::state.
int acmod_process_feat | ( | acmod_t * | acmod, | |
mfcc_t ** | feat | |||
) |
Feed dynamic feature data into the acoustic model for scoring.
Unlike acmod_process_raw() and acmod_process_cep(), this function accepts a single frame at a time. This is because there is no need to do buffering when using dynamic features as input. However, if the dynamic feature buffer is full, this function will fail, so you should either always check the return value, or always pair a call to it with a call to acmod_score().
feat | Pointer to one frame of dynamic features. |
Definition at line 685 of file acmod.c.
References acmod_s::fcb, acmod_s::feat_buf, acmod_s::feat_outidx, acmod_s::grow_feat, acmod_s::n_feat_alloc, and acmod_s::n_feat_frame.
int acmod_process_raw | ( | acmod_t * | acmod, | |
int16 const ** | inout_raw, | |||
size_t * | inout_n_samps, | |||
int | full_utt | |||
) |
Feed raw audio data to the acoustic model for scoring.
inout_raw | In: Pointer to buffer of raw samples Out: Pointer to next sample to be read | |
inout_n_samps | In: Number of samples available Out: Number of samples remaining | |
full_utt | If non-zero, this block represents a full utterance and should be processed as such. |
Definition at line 548 of file acmod.c.
References acmod_s::fe, acmod_s::mfc_buf, acmod_s::mfc_outidx, acmod_s::n_mfc_alloc, acmod_s::n_mfc_frame, and acmod_s::rawfh.
Referenced by ps_process_raw().
int acmod_rewind | ( | acmod_t * | acmod | ) |
Rewind the current utterance, allowing it to be rescored.
After calling this function, the internal frame index is reset, and acmod_score() will return scores starting at the first frame of the current utterance. Currently, acmod_set_grow() must have been called to enable growing the feature buffer in order for this to work. In the future, senone scores may be cached instead.
Definition at line 713 of file acmod.c.
References acmod_s::feat_outidx, acmod_s::n_feat_alloc, acmod_s::n_feat_frame, and acmod_s::output_frame.
int16 const* acmod_score | ( | acmod_t * | acmod, | |
int * | out_frame_idx, | |||
int16 * | out_best_score, | |||
int32 * | out_best_senid | |||
) |
Score one frame of data.
out_frame_idx | Output: frame index corresponding to this set of scores. | |
out_best_score | Output: best un-normalized acoustic score. | |
out_best_senid | Output: senone ID corresponding to best score. |
Definition at line 730 of file acmod.c.
References acmod_s::compallsen, acmod_s::feat_buf, acmod_s::feat_outidx, acmod_s::frame_eval, acmod_s::mgau, acmod_s::n_feat_alloc, acmod_s::n_feat_frame, acmod_s::n_senone_active, acmod_s::output_frame, acmod_s::senone_active, and acmod_s::senone_scores.
Referenced by ngram_fwdflat_search(), and ngram_fwdtree_search().
int acmod_set_grow | ( | acmod_t * | acmod, | |
int | grow_feat | |||
) |
Set memory allocation policy for utterance processing.
grow_feat | If non-zero, the internal dynamic feature buffer will expand as necessary to encompass any amount of data fed to the model. |
Definition at line 358 of file acmod.c.
References acmod_s::grow_feat, and acmod_s::n_feat_alloc.
Referenced by ps_process_raw(), and ps_reinit().
int acmod_set_mfcfh | ( | acmod_t * | acmod, | |
FILE * | logfh | |||
) |
Start logging MFCCs to a filehandle.
acmod | Acoustic model object. | |
logfh | Filehandle to log to. |
Definition at line 320 of file acmod.c.
References acmod_s::mfcfh.
Referenced by ps_start_utt().
int acmod_set_rawfh | ( | acmod_t * | acmod, | |
FILE * | logfh | |||
) |
Start logging raw audio to a filehandle.
acmod | Acoustic model object. | |
logfh | Filehandle to log to. |
Definition at line 332 of file acmod.c.
References acmod_s::rawfh.
Referenced by ps_start_utt().