SPRAAK
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Data Structures | Typedefs | Enumerations | Functions | Variables
API_LowLvl::lib::cwr::am
+ Collaboration diagram for API_LowLvl::lib::cwr::am:

Data Structures

struct  SprHmmIoOD
 
struct  SprHmmUnitSelOD
 
struct  SprHmmProbSelOD
 
struct  SprHmmReadOD
 
struct  SprHmmSetupOD
 
struct  SprHmmWriteOD
 
struct  SprHmmMvg
 
union  SprHmmUchar4
 
union  SprHmmGndxXXPtr
 
struct  SprHmmRmgInfo
 All information for fast selection of gaussians. More...
 
struct  SprHmmMvgs
 
struct  SprHmmState
 
struct  SprHmmStates
 structure describing a set of HMM states More...
 
struct  SprHmmSeg
 
struct  SprHmmSegs
 Structure describing a set of segments. More...
 
struct  SprHmmHmm
 Structure describing the total hmm. More...
 
struct  SprHmmTProb
 
union  SprHmmFGauss
 
struct  SprAcmod
 opaque structure (will become a class) More...
 
struct  SprAmFlagsOD
 

Typedefs

typedef unsigned char SprHmmUchar
 
typedef spr_hmm_gndx_int_or_short SprHmmGndx
 
typedef SprHmmUchar *(* _FuncPtr1_HMMDEF_ )(const struct spr_t_hmm_rmg_info *info, const float *x, const SprHmmUchar *sel_in, SprHmmUchar *restrict sel_out)
 
typedef float *(* _FuncPtr2_HMMDEF_ )(const float *x, SprAcmod *gset, float *restrict oprob)
 
typedef int(* _FuncPtr3_HMMDEF_ )(SprAcmod *gset, int action,...)
 modify the status/configuration More...
 
typedef void *(* _FuncPtr4_HMMDEF_ )(int action, void *search_space, void *ssp_des, void *data, int iframe)
 

Enumerations

enum  { SPR_CWR_AM_STD, SPR_CWR_AM_MDT, SPR_CWR_AM_FDT }
 
enum  { SPR_HMM_VIT, SPR_HMM_FB }
 
enum  { SPR_HMM_LEFT_TO_RIGHT, SPR_HMM_FENON, SPR_HMM_BAKIS, SPR_HMM_NTOPOLOGY }
 
enum  { SPR_HMM_DS_LOG, SPR_HMM_DS_LIN, SPR_HMM_DS_EXP, SPR_HMM_NDATASCALE }
 
enum  { SPR_HMM_SELF_ARC, SPR_HMM_TRANS_ARC, SPR_HMM_NULL_ARC }
 
enum  { SPR_HMM_DD_HMM, SPR_HMM_CD_HMM, SPR_HMM_SC_HMM, SPR_HMM_NDENSTYPE }
 
enum  { SPR_HMM_IWR, SPR_HMM_CWR, SPR_HMM_CSR }
 
enum  {
  SPR_HMM_DO_END, SPR_HMM_DO_STYLE, SPR_HMM_DO_PROB, SPR_HMM_DO_TOP_N,
  SPR_HMM_DO_RMG, SPR_HMM_DO_DUR, SPR_HMM_DO_LMO, SPR_HMM_DO_SELECT,
  SPR_HMM_DO_OPTIONS, SPR_HMM_DO_CVT
}
 
enum  {
  SPR_AM_CALC_LOG, SPR_AM_CALC_POSTPROB, SPR_AM_CALC_VAR_SCALE, SPR_AM_CALC_NORMALIZED,
  SPR_AM_CALC_FLOORED, SPR_AM_CALC_TOT_PROB, SPR_AM_CALC_H, SPR_AM_CALC_MSK
}
 
enum  {
  SPR_AM_CVT_LOG, SPR_AM_CVT_POSTPROB, SPR_AM_CVT_VAR_SCALE, SPR_AM_CVT_NORMALIZED,
  SPR_AM_CVT_FLOORED, SPR_AM_CVT_TOT_PROB, SPR_AM_CVT_H, SPR_AM_CVT_MSK
}
 

Functions

float * spr_am_cvt_oprob (SprAcmod *restrict am, float *restrict pvec, unsigned int fmt)
 
int spr_am_cvt_oprob_set (SprAcmod *restrict am, unsigned int fmt, float asf)
 
SprHmmStatesspr_am_states_struct_alloc (int nstates, int nmix)
 
SprHmmMvgsspr_am_mvgs_struct_alloc (int nmvgs, int ovlen)
 
SprHmmHmmspr_am_hmm_struct_alloc (int nmix, const char *hmmfname, const char *unitfname, const char *mvgfname, const char *selectfname)
 
void spr_am_state_val_init (SprHmmStates *states, int state_nr)
 
int spr_am_state_val_alloc (SprHmmStates *states, int state_nr, int *mixdim)
 
void spr_am_mvg_val_init (SprHmmMvgs *mvgs, int mvg_nr)
 
int spr_am_mvg_val_alloc (SprHmmMvgs *mvgs, int mvg_nr)
 
SprHmmMvgsspr_am_mvgs_val_alloc (int nmvgs, int ovlen)
 
void spr_am_states_aid_init (SprHmmStates *states)
 Initialisation: 'selected' array to one, 'output_prob' to zero. More...
 
int spr_am_states_aid_alloc (SprHmmStates *states)
 
void spr_am_mvgs_aid_init (SprHmmMvgs *mvgs)
 
int spr_am_mvgs_aid_alloc (SprHmmMvgs *mvgs)
 
int spr_am_hmm_aid_alloc (SprHmmHmm *hmm)
 
void spr_am_states_cts_init (SprHmmStates *states)
 Initialises counts (including sum_ct) to zero. More...
 
int spr_am_states_cts_alloc (SprHmmStates *states)
 
void spr_am_mvgs_cts_init (SprHmmMvgs *mvgs)
 Initialises counts (including glob_ct) to zero. More...
 
int spr_am_mvgs_cts_alloc (SprHmmMvgs *mvgs)
 Allocates (and initialises) mvgs counts (mu_ct, sigma_ct). More...
 
int spr_am_hmm_cts_alloc (SprHmmHmm *hmm)
 
SprHmmSegspr_am_seg_alloc (const char *spelling, int nsubsegs)
 
int spr_am_hmm_ct_fprintf (const char *ctfname, const SprHmmHmm *hmm)
 
int spr_am_hmm_ct_fscanf (const char *ctfname, SprHmmHmm *hmm, double fac)
 
void * spr_am_state_free (SprHmmState *state, int nmix)
 
void * spr_am_states_free (SprHmmStates *states)
 
void * spr_am_seg_free (SprHmmSeg *seg)
 
void * spr_am_segs_free (SprHmmSegs *segs)
 
void * spr_am_mvg_free (SprHmmMvg *mvg)
 
void * spr_am_mvgs_free (SprHmmMvgs *mvgs)
 
void * spr_am_hmm_free (SprHmmHmm *hmm)
 
int spr_print_hmminfo (const SprHmmHmm *hmm, SprStream *fptr)
 
int spr_print_states (const SprHmmStates *states, SprStream *fptr, int state_nr)
 
int spr_print_mvgs (const SprHmmMvgs *mvgs, SprStream *fptr, int mvg_nr)
 
int spr_print_seg (const SprHmmSeg *seg, SprStream *fptr)
 Print information about the segment descriptor to file. More...
 
int spr_print_segs (const SprHmmSegs *segs, SprStream *fptr, int seg_nr)
 
int spr_write_hmm (SprHmmHmm *hmm, const char *hmmofname, const char *mvgofname, const char *selectofname, const char *newunitfname)
 
int spr_hmm_select_states (SprHmmHmm *hmm, char *unitselector, int DO_SILENCE, int DO_SPEECH, int DO_GARBAGE)
 
int spr_hmm_normalise (SprHmmHmm *hmm, int TRANSITION, int OUTPUT, SprStream *fd_report)
 
double spr_gauss_dist_symm (const SprHmmMvg *mvg1, const SprHmmMvg *mvg2, int ovlen)
 
double spr_gauss_dist_asymm (const SprHmmMvg *mvg1, const SprHmmMvg *mvg2, int ovlen)
 
void spr_hmm_sim_em0 (float *restrict wgt, int Nmvg, float frac, const SprHmmState *orig_state, int imix)
 
void spr_hmm_sim_em0_bmp (float *restrict wgt, int Nmvg, float frac, const SprHmmState *orig_state, int imix, const unsigned int *bmp)
 
int spr_hmm_sim_em (SprHmmMvg *const *mvg, int ovlen, const SprHmmState *orig_state, SprHmmState *full_state, int imix)
 
int spr_hmm_sim_em2 (SprHmmMvg *const *mvg, int ovlen, const SprHmmState *orig_state, SprHmmState *new_state, int imix, double alpha)
 
SprHmmHmmspr_am_hmm_fscanf (SprHmmHmm *hmm)
 
SprHmmSegsspr_am_unit_fscanf (SprHmmSegs *units, const char *unitfname, int *nstates)
 
int spr_am_dic_fscanf (SprHmmSegs **dic, const char *dicfname, const SprHmmSegs *units)
 
SprHmmMvgsspr_am_mvg_fscanf (SprHmmMvgs *mvgs, const char *mvgfname)
 
SprHmmMvgs ** spr_am_mvgs_fscanf (SprHmmMvgs **mvgs_row, int nmix, const char *mvgfname)
 
SprHmmStatesspr_am_select_fscanf (SprHmmHmm *hmm, const char *selectfname)
 
int spr_am_mvg_apply_exp (SprHmmMvgs *mvgs, const float *exp_vec, int Nvec, const char *fname)
 
int spr_am_hmm_apply_options (SprHmmHmm *hmm, const char *opt_str)
 
SprHmmHmmspr_am_hmm_read_new (const char *hmmfname, const char *unitfname, const char *mvgfname, const char *selectfname, const char *opt_str)
 
int spr_am_hmm_modify (SprHmmHmm *hmm, int type,...)
 
int spr_am_seg_spell2nr (const char *spelling, const SprHmmSegs *segs)
 
int spr_am_datakeys_check (SprHmmHmm *hmm, SprKeySet *keys)
 
SprHmmHmmspr_am_hmm_construct_new (int denstype, const char *unitfname, const char *mvgfname, SprKeySet *keys)
 
int spr_am_hmm_fprintf (const char *hmmfname, const SprHmmHmm *hmm)
 
int spr_am_unit_fprintf (const char *unitfname, const SprHmmSegs *units)
 
int spr_am_dic_fprintf (const char *dicfname, const SprHmmSegs *vocab, const SprHmmSegs *units)
 
int spr_am_mvg_fprintf (const char *mvgfname, const SprHmmMvgs *mvgs)
 
int spr_am_mvgs_fprintf (const char *mvgfname, const SprHmmHmm *hmm)
 
int spr_am_select_fprintf (const char *selectfname, const SprHmmHmm *hmm)
 
int spr_am_fprintf (SprHmmHmm *hmm, const char *hmmfname, const char *mvgfname, const char *selfname)
 
int spr_am_flags_decode (const char *opt_str, int msk, SprAmFlagsOD *restrict dd, float *sf)
 

Variables

const SprCwrSRMDesc *const spr_cwr_am_desc []
 
const char *const spr_cwr_str_am_desc []
 
const SprOptDesc spr_hmm_load_od []
 
const SprOptDesc spr_hmm_save_od []
 Description of program arguments related to hmm writing. More...
 
const SprOptDesc spr_hmm_unit_sel_od []
 Description of program arguments related to unit selection. More...
 
const SprOptDesc spr_hmm_prob_sel_od []
 
const SprOptDesc spr_hmm_read_od []
 
const SprCmdOptDesc spr_hmm_std_od []
 
const SprOptDesc spr_hmm_setup_od []
 
char * spr_am_script_byte2short []
 
const SprOptDesc spr_hmm_write_od []
 
const char *const spr_hmm_str_topology [SPR_HMM_NTOPOLOGY+1]
 
const char *const spr_hmm_str_datascale [SPR_HMM_NDATASCALE+1]
 
const char *const spr_hmm_str_denstype [SPR_HMM_NDENSTYPE+1]
 
const char *const spr_hmm_str_recogmode []
 
const SprHmmMvg spr_hmm_empty_mvg
 
const SprHmmMvgs spr_hmm_empty_mvgs
 
const SprHmmState spr_hmm_empty_state
 
const SprHmmStates spr_hmm_empty_states
 
const SprHmmHmm spr_hmm_empty_hmm
 
const SprAcmod spr_empty_acmod
 
const SprCmdOptDesc spr_am_flags_od []
 

Detailed Description

Typedef Documentation

typedef unsigned char SprHmmUchar
typedef spr_hmm_gndx_int_or_short SprHmmGndx
typedef SprHmmUchar*(* _FuncPtr1_HMMDEF_)(const struct spr_t_hmm_rmg_info *info, const float *x, const SprHmmUchar *sel_in, SprHmmUchar *restrict sel_out)
typedef float*(* _FuncPtr2_HMMDEF_)(const float *x, SprAcmod *gset, float *restrict oprob)

the main evaluation function: computes the (log) likelihood or the (log) posterior prob; the actual format of the output of this routine is described by the flags <flags> (and the scale factor <log_sf>)

typedef int(* _FuncPtr3_HMMDEF_)(SprAcmod *gset, int action,...)

modify the status/configuration

typedef void*(* _FuncPtr4_HMMDEF_)(int action, void *search_space, void *ssp_des, void *data, int iframe)

the acoustic model requires a call-back from the search (feedback loop)

Enumeration Type Documentation

anonymous enum
Enumerator
SPR_CWR_AM_STD 
SPR_CWR_AM_MDT 
SPR_CWR_AM_FDT 
anonymous enum
Enumerator
SPR_HMM_VIT 
SPR_HMM_FB 
anonymous enum
Enumerator
SPR_HMM_LEFT_TO_RIGHT 
SPR_HMM_FENON 
SPR_HMM_BAKIS 
SPR_HMM_NTOPOLOGY 
anonymous enum
Enumerator
SPR_HMM_DS_LOG 
SPR_HMM_DS_LIN 
SPR_HMM_DS_EXP 
SPR_HMM_NDATASCALE 
anonymous enum
Enumerator
SPR_HMM_SELF_ARC 
SPR_HMM_TRANS_ARC 
SPR_HMM_NULL_ARC 
anonymous enum
Enumerator
SPR_HMM_DD_HMM 
SPR_HMM_CD_HMM 
SPR_HMM_SC_HMM 
SPR_HMM_NDENSTYPE 
anonymous enum
Enumerator
SPR_HMM_IWR 

single word

SPR_HMM_CWR 

single sentence

SPR_HMM_CSR 

multiple sentences

anonymous enum
Enumerator
SPR_HMM_DO_END 
SPR_HMM_DO_STYLE 
SPR_HMM_DO_PROB 
SPR_HMM_DO_TOP_N 
SPR_HMM_DO_RMG 
SPR_HMM_DO_DUR 
SPR_HMM_DO_LMO 
SPR_HMM_DO_SELECT 
SPR_HMM_DO_OPTIONS 
SPR_HMM_DO_CVT 
anonymous enum

flags that describe the output format of the calc_oprob() routine

Enumerator
SPR_AM_CALC_LOG 

the values returned by calc_oprob() are log values

SPR_AM_CALC_POSTPROB 

the values returned by calc_oprob() are (log) posteriors

SPR_AM_CALC_VAR_SCALE 

the scale factor <log_sf> can be changed dynamically, i.e. be a bit more conservative in setting up conversion routine

SPR_AM_CALC_NORMALIZED 

the output of calc_oprob() is normalized, i.e. the sum of the posteriors equals 1.0 (hence the total likelihood is known and thus SPR_AM_CALC_TOT_PROB must be set as well)

SPR_AM_CALC_FLOORED 

a floor value has been added to the likelihood

SPR_AM_CALC_TOT_PROB 

calc_oprob() sets the total likelhood <tot_prob>

SPR_AM_CALC_H 

calc_oprob() computes the entropy (and hence also the total likelihood, ergo SPR_AM_CALC_TOT_PROB must be set as well)

SPR_AM_CALC_MSK 

isolate the SPR_AM_CALC_... flags

anonymous enum

flags that describe the (desired) output format of the cvt_oprob() routine

Enumerator
SPR_AM_CVT_LOG 

the values computed by cvt_oprob() are log values

SPR_AM_CVT_POSTPROB 

the values computed by cvt_oprob() are (log) posteriors

SPR_AM_CVT_VAR_SCALE 

indicate that cvt_oprob() cannot assume that <asf> equals 1.0

SPR_AM_CVT_NORMALIZED 

the output of cvt_oprob() is normalized, i.e. the sum of the posteriors equals 1.0 (hence the total likelihood is known and thus SPR_AM_CVT_TOT_PROB must be set as well)

SPR_AM_CVT_FLOORED 

a floor value is added to the likelihood

SPR_AM_CVT_TOT_PROB 

cvt_oprob() sets the total likelhood <tot_prob>

SPR_AM_CVT_H 

cvt_oprob() computes the entropy (and hence also the total likelihood, ergo SPR_AM_CVT_TOT_PROB must be set as well)

SPR_AM_CVT_MSK 

isolate the SPR_AM_CVT_... flags

Function Documentation

float* spr_am_cvt_oprob ( SprAcmod *restrict  am,
float *restrict  pvec,
unsigned int  fmt 
)
int spr_am_cvt_oprob_set ( SprAcmod *restrict  am,
unsigned int  fmt,
float  asf 
)

Set am->cvt_oprob() to a routine that convert the input data (computed by am->calc_oprob()) to some desired format described by fmt. The bit flags in fmt must be a combination of SPR_AM_CVT_... flags. A non-zero value for asf means that the acoustic scale factor am->asf and its counterpart am->log_sf both can be assumed to be constant (will not be modified on the fly), which allows a bit more aggressive selection of the optimal conversion routine.

SprHmmStates* spr_am_states_struct_alloc ( int  nstates,
int  nmix 
)

Allocates States structure, fills in nstates and nmix, allocates total_mixdim and *state arrays and fills these arrays with 0 and NULL resp..

SprHmmMvgs* spr_am_mvgs_struct_alloc ( int  nmvgs,
int  ovlen 
)

Allocates Mvgs structure, fills in nmvgs and ovlen, allocates *mvg array and initialises the elements to NULL pointers.

SprHmmHmm* spr_am_hmm_struct_alloc ( int  nmix,
const char *  hmmfname,
const char *  unitfname,
const char *  mvgfname,
const char *  selectfname 
)

Allocates Hmm structure, fills in nmix, allocates *mvgs array and initialises the elements to NULL pointers. Duplicates the filenames into the structure.

void spr_am_state_val_init ( SprHmmStates states,
int  state_nr 
)

Initialise state state_nr: probabilities (weight and trans) uniform, selection of gaussians (if reduced SC-HMM) to zero, bias to zero, sum_ct to zero.

int spr_am_state_val_alloc ( SprHmmStates states,
int  state_nr,
int *  mixdim 
)

Allocate state state_nr in the states structure. The state structure is allocated, array state->mixdim is allocated and filled in with the given mixdim array; weight, trans and bias are allocated, and state2mvg for a reduced SC-HMM. The allocated state is initialised.

void spr_am_mvg_val_init ( SprHmmMvgs mvgs,
int  mvg_nr 
)

Initialises a gaussian: mean to zero, sigma to one, logsigprod to zero, glob_ct to zero.

int spr_am_mvg_val_alloc ( SprHmmMvgs mvgs,
int  mvg_nr 
)

Allocate mvg mvg_nr in the mvgs structure. The mvg structure is allocated; mu and sigma are allocated. The allocated mvg is initialised.

SprHmmMvgs* spr_am_mvgs_val_alloc ( int  nmvgs,
int  ovlen 
)

Allocate memory for nmvgs gaussians with length ovlen: alloc_mvgs_struct is called, and nmvgs times alloc_mvg_val (this way initialising too).

void spr_am_states_aid_init ( SprHmmStates states)

Initialisation: 'selected' array to one, 'output_prob' to zero.

int spr_am_states_aid_alloc ( SprHmmStates states)

Allocates (and initialises) 'selected' and 'output_prob' arrays.

void spr_am_mvgs_aid_init ( SprHmmMvgs mvgs)

Initialisation: selection arrays to one, probabilities and indices to zero.

int spr_am_mvgs_aid_alloc ( SprHmmMvgs mvgs)

Allocates (and initialises) arrays namely 'selected', 'orig_selected', 'pvec', 'index' and 'ptop'.

int spr_am_hmm_aid_alloc ( SprHmmHmm hmm)

Calls alloc_states_aid() and nmix times alloc_mvgs_aid() if not discrete.

void spr_am_states_cts_init ( SprHmmStates states)

Initialises counts (including sum_ct) to zero.

int spr_am_states_cts_alloc ( SprHmmStates states)

Allocates (and initialises) the 'trans_ct' and 'weight_ct' array in all states.

void spr_am_mvgs_cts_init ( SprHmmMvgs mvgs)

Initialises counts (including glob_ct) to zero.

int spr_am_mvgs_cts_alloc ( SprHmmMvgs mvgs)

Allocates (and initialises) mvgs counts (mu_ct, sigma_ct).

int spr_am_hmm_cts_alloc ( SprHmmHmm hmm)

Calls alloc_states_cts and nmix times alloc_mvgs_cts if discrete.

SprHmmSeg* spr_am_seg_alloc ( const char *  spelling,
int  nsubsegs 
)

Allocate a SprHmmSeg structure, fills in the nsubsegs and spelling (strdup) fields, and allocates the subsegnr row.

Returns
NULL on error, allocated structure else.
Parameters
spellingspelling of the segment
nsubsegsnumber of subsegs in the segment
int spr_am_hmm_ct_fprintf ( const char *  ctfname,
const SprHmmHmm hmm 
)

Write a HMM statistics file (KEY file format). The data is written state per state:

  • the size of each mixture (hmm->mixdim) (hmm->nmix doubles)
  • the total data point count for the state (one double)
  • the transition probability counts (tpdim doubles)
  • the weight counts for each of the mixtures (sum(hmm->mixdim) doubles)

All necessary fields in hmm should be filled in, no checks on NULL pointers.

Returns
On success zero is returned, on error -1.
int spr_am_hmm_ct_fscanf ( const char *  ctfname,
SprHmmHmm hmm,
double  fac 
)

Read the HMM statistics from file ctfname and add them (weighted with a factor fac) to statistics already present in hmm. Entering this routine, the Hmm structure hmm should be fully initialized and memory for the statistics should already be allocated.

Returns
On success zero is returned, on error -1.
void* spr_am_state_free ( SprHmmState state,
int  nmix 
)

Frees the State structure. Does nothing in the NULL pointer case, else all no-NULL pointers are freed.

Returns
NULL
void* spr_am_states_free ( SprHmmStates states)

Frees the States structure. Does nothing in the NULL pointer case, else all no-NULL pointers are freed.

Returns
NULL
void* spr_am_seg_free ( SprHmmSeg seg)

Free one SprHmmSeg structure. Does nothing in the NULL pointer case, else all non-NULL pointers are freed.

Returns
NULL
void* spr_am_segs_free ( SprHmmSegs segs)

Free the SprHmmSegs structure. Does nothing in the NULL pointer case, else all non-NULL pointers are freed.

Returns
NULL
void* spr_am_mvg_free ( SprHmmMvg mvg)

Frees the Mvg structure. Does nothing in the NULL pointer case, else all no-NULL pointers are freed.

Returns
NULL
void* spr_am_mvgs_free ( SprHmmMvgs mvgs)

Frees the Mvgs structure. Does nothing in the NULL pointer case, else all no-NULL pointers are freed.

Returns
NULL
void* spr_am_hmm_free ( SprHmmHmm hmm)

Frees the whole Hmm structure. Does nothing in the NULL pointer case, else all no-NULL pointers are freed.

Returns
NULL
int spr_print_hmminfo ( const SprHmmHmm hmm,
SprStream fptr 
)

Print the describing fields of an Hmm structure in text format to the given file-descriptor.

int spr_print_states ( const SprHmmStates states,
SprStream fptr,
int  state_nr 
)

If state_nr is negative, all arrays in the States structure are printed to the given file-descriptor, else only the state state_nr is printed.

int spr_print_mvgs ( const SprHmmMvgs mvgs,
SprStream fptr,
int  mvg_nr 
)

If mvg_nr is negative, all arrays in the Mvgs structure are printed to the given file-descriptor, else only the mvg mvg_nr is printed.

int spr_print_seg ( const SprHmmSeg seg,
SprStream fptr 
)

Print information about the segment descriptor to file.

int spr_print_segs ( const SprHmmSegs segs,
SprStream fptr,
int  seg_nr 
)

If seg_nr is negative, all segments in the Segs structure are printed to the given file-descriptor, else only the segment seg_nr is printed.

int spr_write_hmm ( SprHmmHmm hmm,
const char *  hmmofname,
const char *  mvgofname,
const char *  selectofname,
const char *  newunitfname 
)

Write the HMM hmm to the given files. For those file names that are NULL pointers, the file that information (hmm, mvg, sel) was read from will be overwritten.

Returns
(-1) on failure, (0) otherwise.
int spr_hmm_select_states ( SprHmmHmm hmm,
char *  unitselector,
int  DO_SILENCE,
int  DO_SPEECH,
int  DO_GARBAGE 
)

Mark some states as 'selected'. The states to select can be specified either by the string unitselector, or, if unitselector equals NULL, a combination of flags:

DO_SILENCE
if not zero, then select all silence states
DO_SPEECH
if not zero, then select all speech states
DO_GARBAGE
if not zero, then select all garbage states

The unitselector string has the format '<unit>' or '[unit]#<first>[:last]'. If the indices <first> and <last> (base 0) are not specified, all states of all selected units are selected. If only <first> is specified, and not <last>, only <first> is selected. Else, <first> ... <last> are selected.

Returns
(-1) on error (invalid selection), (0) otherwise.
int spr_hmm_normalise ( SprHmmHmm hmm,
int  TRANSITION,
int  OUTPUT,
SprStream fd_report 
)

Normalize the probability distribution (transition and observation) for the 'selected' states in the HMM hmm. If neither TRANSITION not OUTPUT is set, both the transition and observation probability distributions will be nromalized.

Returns
(-1) on error and (0) otherwise.
Parameters
hmmnormalises selected states in this HMM
TRANSITIONnormalize the transition probs
OUTPUTnormalize the output probs
fd_reportreport every checksum to this fill (if not NULL)
double spr_gauss_dist_symm ( const SprHmmMvg mvg1,
const SprHmmMvg mvg2,
int  ovlen 
)

Calculate the distance from one single gaussian to an other single gaussian, the measure is symmetric.

double spr_gauss_dist_asymm ( const SprHmmMvg mvg1,
const SprHmmMvg mvg2,
int  ovlen 
)

Calculate the overlap from one single gaussian to an other single gaussian + compensate when mvg1 encompasses a smaller volume than mvg2 (See PhD Kris Demuynck, page 101). Note that the compensation results in a non symmetric measure.

void spr_hmm_sim_em0 ( float *restrict  wgt,
int  Nmvg,
float  frac,
const SprHmmState orig_state,
int  imix 
)

Initialize the weight vector wgt for a new full sized Gaussian mixture (no tied Gaussians) starting from the mixture with tied Gaussians orig_state. The weight distribution is frac times the uniform distribution plus (1-frac) the distribution found in orig_state.

void spr_hmm_sim_em0_bmp ( float *restrict  wgt,
int  Nmvg,
float  frac,
const SprHmmState orig_state,
int  imix,
const unsigned int *  bmp 
)

Initialize the weight vector wgt for a new full sized Gaussian mixture (no tied Gaussians) starting from the mixture with tied Gaussians orig_state. The weight distribution is frac times the uniform distribution plus (1-frac) the distribution found in orig_state. Only the Gaussians which have their bit set to 1 in bmp will have a non zero weight. If bmp equals NULL, all Gaussians will be used.

int spr_hmm_sim_em ( SprHmmMvg *const *  mvg,
int  ovlen,
const SprHmmState orig_state,
SprHmmState full_state,
int  imix 
)

Do one EM iteration to update the full sized Gaussian mixture (no tied Gaussians) full_state given data distributed as described by orig_state.

Returns
(-1) on failure (out of memory) and (0) otherwise.
int spr_hmm_sim_em2 ( SprHmmMvg *const *  mvg,
int  ovlen,
const SprHmmState orig_state,
SprHmmState new_state,
int  imix,
double  alpha 
)

Do one EM iteration to update the Gaussian mixture (tied Gaussians) new_state given data distributed as described by orig_state.

Returns
(-1) on failure (out of memory) and (0) otherwise.
Note
new_state and orig_state must have identical gaussian mixtures, except for the weights.
SprHmmHmm* spr_am_hmm_fscanf ( SprHmmHmm hmm)

Read the HMM-file (written as key-file). Entering this routine, the Hmm structure hmm should be allocated, the hmm->hmmfname field should be filled in and the other three file names should be non-NULL. If they are the empty string, the name found in the hmm keys is filled in. Fields hmm->states, hmm->units and hmm->mvgs are NULL pointers. First, all hmm describing values are extracted from the keys in the hmm file given by hmm->hmmfname, and filled in in the describing fields of the Hmm structure and its substructures states and mvgs. These substructures will be allocated, along with all their own substructures for the values from hmm file, mvg file(s) and select file. Field hmm->units remains a NULL pointer. The probabilities for the states are read from the hmm file, and filled in in the hmm->states->state[] structure.

Returns
NULL on failure, pointer to the hmm else. On error, the whole hmm is freed.
SprHmmSegs* spr_am_unit_fscanf ( SprHmmSegs units,
const char *  unitfname,
int *  nstates 
)

The description of the units is read from the given unit file. The lines in the unit file (after the header) have the following form:

SPELLING NSTATES [STATE_NRS] ...

First the spelling is given, then the number of states in the unit, then the numbers of these states in the HMM file. The last is optional: if not given, state numbering is continued from they highest state number encountered before (or starting with zero for the first line). If nstates differs from -1, an error is returned if a state number is higher than the total number of states in the HMM (nstates). If nstates is -1, the highest state number used + 1 is filled in (which automatically becomes the new highest state number).

If units is a NULL pointer, the structure is allocated and field nsegs is filled in. If units is not a NULL pointer, the nsegs field should be filled in; if it differs from the value in the file, this routine results in an error, except if the value is SPR_NOT_DEFINED, then it is filled in. The row of Seg structures is always allocated in this routine, along with the Seg structures themselves (free first if necessary).

Returns
On error, NULL is returned and the Segs structure is freed. Else, a pointer to the Segs structure is returned.
int spr_am_dic_fscanf ( SprHmmSegs **  dic,
const char *  dicfname,
const SprHmmSegs units 
)

Read/add the vocabulary from the given dictionary file. The lines in the dictionary file (after the header) have the following form: SPELLING_OF_WORD SEQUENCE_OF_UNITS If the units structure is a NULL pointer, only the spelling is read, the unit level description is not filled in. Else, the sequence of units is read and the corresponding units numbers are filled in in the Seg structures. In the second case, a dictionary entry is thrown away if there is an unknown unit in it, a message then will be written.

The new vocabulary is added to the one pointed to with *dic (NULL for the first dictionary).

Returns
If an error occurs, the old dictionary is restored, -1 is returned. Else, the number of correct words found is returned.
SprHmmMvgs* spr_am_mvg_fscanf ( SprHmmMvgs mvgs,
const char *  mvgfname 
)

Reads mean and variances of multivariable gaussian densities from the given file (written as key-file) into a mvg structure, fills in logsigprod. If mvgs is a NULL pointer, the structures are allocated, fields nmvgs and ovlen are filled in, and other Mvgs structure fields are set to NULL or zero. If mvgs is not a NULL pointer, the nmvgs and olven field should be filled in and all Mvg structures should be allocated. If the dimensions differ from the corresponding numbers in the file, this routine results in an error.

Returns
On error, NULL is returned and the Mvgs structure is freed. Else, a pointer to the Mvgs structure is returned.
SprHmmMvgs** spr_am_mvgs_fscanf ( SprHmmMvgs **  mvgs_row,
int  nmix,
const char *  mvgfname 
)

Reads an array of nmix Mvgs structures (with fscanf_mvg()). The given file name mvgfname is extended with 0, 1, ... , nmix-1, except if only one mvg should be read, then there is no extension. If mvgs_row is a NULL pointer, the array is allocated. For possible checking of values in mvgs_row[imix], see the manual about fscanf_mvg().

Returns
On error (allocation failed, wrong Mvgs dimensions, error from check_mvg), NULL is returned and the array of Mvgs structures is freed. Else, a pointer to the array of Mvgs structures is returned.
SprHmmStates* spr_am_select_fscanf ( SprHmmHmm hmm,
const char *  selectfname 
)

Reads from the given file the indices for the correspondence between the State->weight weights and the mvgs. The fields nstates, nmix and mixdim in de states structure should be filled in when entering this routine. They will be checked, inconsistencies result in an error for the routine. All necessary memory (state2mvg arrays) should already be allocated, no checks on this. The nmvgs fields should be filled in. It is checked if the state2mvg arrays are of the correct type (SHORT, INT) to fit the indices.

Returns
On error, NULL is returned and the hmm->states structure is freed. Else, hmm->states is filled in and a pointer to the states structure is returned.
int spr_am_mvg_apply_exp ( SprHmmMvgs mvgs,
const float *  exp_vec,
int  Nvec,
const char *  fname 
)

Apply the exponents to the Gaussians. The exponent is either specified as a vector or matrix (argument exp_vec) or as a file containing the vector/matrix (argument fname). The argument Nvec should either be (-1), 1, or equal to the number of gaussians. If Nvec equals 1, then the gaussian exponents are assumed to be a single vector, i.e. the same exponents are applied for each gaussian. A value equal to the number of gaussians (or any value different than 1 and -1 if the exponents are read from file) indicates a different set of exponents per gaussian. A (-1) value indicates that both are possible (requires that the gaussian exponents are read from a file).

Returns
0 on success and (-1) on failure.
int spr_am_hmm_apply_options ( SprHmmHmm hmm,
const char *  opt_str 
)

Reads the data from the different files (.hmm, .mvg, .sel).

Returns
The new hmm is returned, or NULL on error.
SprHmmHmm* spr_am_hmm_read_new ( const char *  hmmfname,
const char *  unitfname,
const char *  mvgfname,
const char *  selectfname,
const char *  opt_str 
)

Reads the data from the different files (.hmm, .mvg, .sel).

Returns
The new hmm is returned, or NULL on error.
int spr_am_hmm_modify ( SprHmmHmm hmm,
int  type,
  ... 
)

Modify an given Hmm. The first argument is the Hmm pointer, which must point to an initialised Hmm structure with all necessary sub-structures as when it is read from the HMM files (NO checks for NULL pointers). Then in the routine arguments the first modification follows with its specific arguments (called 'info' in the text below), then the second modification and so on. End with the DO_END command.

Returns
0 if everything was OK, -1 when trouble in a modification occurred but this was solved by defaulting, SPR_NOT_DEFINED for unknown modifications.
Note
The routine does not stop on the first problem, all modifications asked for are executed and the strongest error code is returned. Possible error codes for each modification are given along with their description.

Possible modifications:

DO_END
End this way when all modifications are made.
info: /
DO_STYLE
Change the training/testing style (Viterbi or Forward-Backward), change transition probs accordingly (logarithmical resp. linear).
info: (int) VIT or FB
Return value: 0 (style set) or -1 (unknown style, nothing done).
DO_PROB
Change output probs to logarithmical for discrete HMMs or to linear for continuous HMMs.
info: /
Return value: 0.
DO_TOP_N
Check and set top_n for the gaussian mixtures. info: (char *) string with the top_n value(s), separated by commas if different top_n for the different mixtures
Return value: 0 or -1 (error, defaulted to "0").
DO_RMG
Set the rmg for the gaussian mixtures.
info: (char*) string with the rmg value(s), separated by commas if different rmg needed for the different mixtures
Return value: 0 or -1 (error, defaulted to "no").
DO_DUR
Set duration value
info: (int) the (new) value
Return value: 0 or -1 (illegal value, defaulted to 1).
DO_LMO
Set logminout value
info: (float) the (new) value
Return value: 0.
DO_SELECT
Sets the 'orig_selected' and 'selected' arrays in the Mvgs structures:
  • for a reduced SC_HMM, according to the state2mvg arrays for the selected states (states->selected).
  • for the other continuous cases, to 1.
info: /
Return value: 0.
Note
Should be done when the rmg is already set (DO_RMG).
'selected' is initialised to 'orig_selected' because select_rmg() does not copy for NULL rmg.
int spr_am_seg_spell2nr ( const char *  spelling,
const SprHmmSegs segs 
)

Search for the (first) unit with the given spelling and returns its number.

Returns
Number of the unit if found, else -1.
int spr_am_datakeys_check ( SprHmmHmm hmm,
SprKeySet keys 
)

Checks if the keys in a data keyset are compatible with the values in the given hmm.

Returns
Zero if compatible or NULL hmm, returns -1 else.
SprHmmHmm* spr_am_hmm_construct_new ( int  denstype,
const char *  unitfname,
const char *  mvgfname,
SprKeySet keys 
)

Constructs Hmm from keys (observations, units, (mvgs)). Reads the units. String mvgfname is not important for DD_HMM, it should differ from the empty string for SC_HMM. For CD_HMM, one gaussian per state is chosen if it is empty. Given file names should not be NULL (use the empty string if a file is not necessary).

Returns
The new hmm or NULL on error.
int spr_am_hmm_fprintf ( const char *  hmmfname,
const SprHmmHmm hmm 
)

Write a HMM data file (KEY file format). The data is written state per state:

  • the size of each mixture (hmm->mixdim) (nmix floats)
  • the total data point count for the state (one float)
  • the bias for each mixture (hmm->nmix floats)
  • the transition probabilities (hmm->tpdim floats)
  • the weights for each of the mixtures (sum(hmm->mixdim) floats)

All necessary fields in hmm should be filled in, no checks on NULL pointers.

Returns
Zero on success, -1 on error.
int spr_am_unit_fprintf ( const char *  unitfname,
const SprHmmSegs units 
)

Print a unit file with the given units. No checks on NULL fields in the units structure.

Returns
-1 on error (file could not be opened) or 0 on success.
int spr_am_dic_fprintf ( const char *  dicfname,
const SprHmmSegs vocab,
const SprHmmSegs units 
)

Prints a dictionary file with the given vocabulary and units. No checks on NULL fields in the units of vocab structures.

Returns
0 if no problems occured and (-1) on errors (one or more words consisted of invalid units, file could not be opened, out of memory, ...).
int spr_am_mvg_fprintf ( const char *  mvgfname,
const SprHmmMvgs mvgs 
)

Writes the set of multi variate gaussian densities in the mvgs structure to the file mvgfname (KEY file format). The data is written gaussian per gaussian:

  • the total data point count for the gaussian (one float)
  • the mean of the gaussian (mvgs->ovlen floats)
  • the sigma (deviation) of the gaussian (mvgs->ovlen floats)

No checks for NULL fields in the mvgs structure. Returns -1 on error (file could not be opened), 0 on success.

int spr_am_mvgs_fprintf ( const char *  mvgfname,
const SprHmmHmm hmm 
)

Writes the hmm->nmix sets of mvgs in hmm->mvgs. For the different files, the given filename mvgfname is extended with the number of the mvgs set to make the difference in name (no extension if there is only one mvgs set). No checks on NULL fields in the hmm: all necessary fields should be filled in.

Returns
-1 on error (file can not be opened, allocation of filename failed), zero on success.
int spr_am_select_fprintf ( const char *  selectfname,
const SprHmmHmm hmm 
)

Write a select data file (KEY file format). The data is written state per state:

  • the size of each mixture (hmm->mixdim) (hmm->nmix values)
  • the indices for the gaussians in each of the mixtures (sum(hmm->mixdim) values)

The values are written as shorts if possible, as integers else. To check if shorts are possible, the 'nmvgs' fields in hmm->mvgs[i] should be filled in. For each state and mixture of a reduced SC_HMM, an index row is given. These indices give the gaussians corresponding to the weighting values in the states. No checks on NULL fields in the hmm->states structure, all necessary fields should be filled in.

Returns
On success zero is returned; if flag hmm->states->reduced_SC_HMM is false, -1; on error (file could not be opened), -2.
int spr_am_fprintf ( SprHmmHmm hmm,
const char *  hmmfname,
const char *  mvgfname,
const char *  selfname 
)

Write the main files that make up the (trainable part of an) acoustic model. If a file name equals NULL, that component is not written out. Components that are not available are also not written out.

Returns
0 on success and -1 on failure.
int spr_am_flags_decode ( const char *  opt_str,
int  msk,
SprAmFlagsOD *restrict  dd,
float *  sf 
)

Decode the settings that describe the features returned by the acoustic model likelihood/probability calcultations (msk==SPR_AM_CALC_MSK; describe the values returned by calc_oprob) or the features returned by the likelihood/probability conversion routine (msk===SPR_AM_CVT_MSK; describe the values that cvt_oprob should return). By default the settings in opt_str are decoded and stored in dd (if dd equals NULL, an internal buffer is used). If opt_str equals NULL, the decoding start from the values found in *dd. The decoded flags can be found in *dd (if dd is not NULL) and are returned as bitmap flags as well. If sf is not NULL, the log scale factor (or linear power factor) is also stored in *sf (typically used if dd equals NULL).

Returns
a bitmap flag corresponding to the flags set (and masked with msk) on success or (-1) on failure.

Variable Documentation

const SprCwrSRMDesc* const spr_cwr_am_desc[]
const char* const spr_cwr_str_am_desc[]
const SprOptDesc spr_hmm_load_od[]

Description of program arguments related to hmm loading and handling.

const SprOptDesc spr_hmm_save_od[]

Description of program arguments related to hmm writing.

const SprOptDesc spr_hmm_unit_sel_od[]

Description of program arguments related to unit selection.

const SprOptDesc spr_hmm_prob_sel_od[]

Description of program arguments related to hmm loading and handling.

const SprOptDesc spr_hmm_read_od[]

Description of all program arguments related to acoustic model loading.

const SprCmdOptDesc spr_hmm_std_od[]
const SprOptDesc spr_hmm_setup_od[]

Description of all program arguments related to acoustic model setup.

char* spr_am_script_byte2short[]
const SprOptDesc spr_hmm_write_od[]

Description of all program arguments related to model reestimation.

const char* const spr_hmm_str_topology[SPR_HMM_NTOPOLOGY+1]
const char* const spr_hmm_str_datascale[SPR_HMM_NDATASCALE+1]
const char* const spr_hmm_str_denstype[SPR_HMM_NDENSTYPE+1]
const char* const spr_hmm_str_recogmode[]
const SprHmmMvg spr_hmm_empty_mvg
const SprHmmMvgs spr_hmm_empty_mvgs
const SprHmmState spr_hmm_empty_state
const SprHmmStates spr_hmm_empty_states
const SprHmmHmm spr_hmm_empty_hmm
const SprAcmod spr_empty_acmod
const SprCmdOptDesc spr_am_flags_od[]