#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include "segCommon.h"
#include "segStdLib.h"
#include "segModel.h"
Functions | |
| static double * | readVector (double *vec, FILE *fp, int dim) |
| Read a vector from a given file stream. | |
| static int | writeVector (double *vec, FILE *fp, int dim) |
| Write a vector to a given file stream. | |
| static double ** | readMatrix (double **mat, FILE *fp, int nrow, int ncol) |
| Read a matrix from a file stream given. | |
| static int | writeMatrix (double **mat, FILE *fp, int nrow, int ncol) |
| Write a matrix to a file stream given. | |
| static double * | readParameter (FILE *fp, int dim) |
| Allocate memory space, read a matrix from a file stream given, and store the matrix in the allocated space. | |
| static double ** | readMapping (FILE *fp, int domainDim, int rangeDim) |
| Read a map matrix. | |
| static int | readParamAccum (double **param, double **accum, FILE *fp, int dim) |
| Load a parameter vector from a model file. | |
| static SEG_TRJ * | readVariance (SEG_TRJ *trajModel, FILE *fp, int dim) |
| Read and store a variance vector. | |
| static SEG_TRPROB * | readTransProbs (FILE *fp) |
| Read and store a transition probability matrix. | |
| static SEG_DUR * | readDurModel (FILE *fp, int maxDur) |
| Read and store a durational distribution. | |
| static char * | readLabel (char *line) |
| Read a label from a given char array. | |
| static SEG_TRJ * | readTrjModel (FILE *fp) |
| Read a trajectory model. | |
| static SEG_MAP * | readMappings (FILE *fp) |
| Read a set of forward and inverse map matrices. | |
| static SEG_STATE * | readStateInfo (SEG_STATE *state, FILE *fp, int numDur) |
| Read model parameters of an emitting state. | |
| static int | readHeader (int *numStream, int *streamSize, int *vecSize, int *targetVecSize, FILE *fp) |
| Read the header of model definition. | |
| static SEG_MODEL_SET * | readModelSet (char *modelList, int maxDur) |
| Read a set of multi-level segmental-HMMs in the file of model name list. | |
| static SEG_MDPARAM * | readModel (FILE *fp, int maxDur) |
| Read a single model. | |
| static int | tieModelParameters (SEG_MODEL_SET *modelset) |
| Tie model parameters. | |
| static int | countModels (SEG_MODEL_SET *modelset, int nLines, FILE *fp_list) |
| Count all the different levels of models. | |
| static int | buildLogicalModels (SEG_MODEL_SET *modelset, char *tiedList) |
| Read tied list file and build the logical layer of the models. | |
| static int | writeStateInfo (FILE *fp, SEG_STATE *state) |
| Write model parameters for an emitting state. | |
| int | segMakeStrictLRTopology (SEG_MODEL_SET *modelset) |
| Force models to maintain strict left-to-right topology. | |
| int | segCheckModelSet (SEG_MODEL_SET *modelset) |
| Check the consistency of model parameter set. | |
| SEG_MODEL_SET * | segReadModelSet (char *modelList, char *tiedList, int maxDur) |
| Read a set of multi-level segmental-HMMs in the file of model name list. | |
| int | segWriteModelSet (SEG_MODEL_SET *modelset, FILE *fp) |
| Write a set of models to a file. | |
| int | segWriteDump (SEG_MODEL_SET *modelset, char *fName) |
| Write dump file contents. | |
| static int buildLogicalModels | ( | SEG_MODEL_SET * | modelset, | |
| char * | tiedList | |||
| ) | [static] |
Read tied list file and build the logical layer of the models.
| [in,out] | modelset | Model set |
| [in] | tiedList | Name of file containing tied phone list |
| ERROR_ALLOC | Memory allocation error | |
| ERROR_FOPEN | File open error | |
| ERROR_FREAD | File read error | |
| RTN_ERROR | Inconsistency found in the list | |
| NO_ERROR | Successfully executed |
| static int countModels | ( | SEG_MODEL_SET * | modelset, | |
| int | nLines, | |||
| FILE * | fp_list | |||
| ) | [static] |
Count all the different levels of models.
This function counts how many physical models, transition probability matrices, states, trajectory models, duration models and articulatory-acoustic map matrices are in the model set.
| [in,out] | modelset | Model set |
| [in] | nLines | Number of lines in the model file |
| [in] | fp_list | File pointer |
| RTN_ERROR | File open error | |
| NO_ERROR | Successful execution |
| static SEG_DUR * readDurModel | ( | FILE * | fp, | |
| int | maxDur | |||
| ) | [static] |
Read and store a durational distribution.
| [in] | fp | File pointer from which the distribution is loaded |
| [in] | maxDur | Maximum segment-duration |
| NULL | Memory allocation error / File read error | |
| otherwise | Pointer to the structure (durModel) variable where the distribution is stored |
| static int readHeader | ( | int * | numStream, | |
| int * | streamSize, | |||
| int * | vecSize, | |||
| int * | targetVecSize, | |||
| FILE * | fp | |||
| ) | [static] |
Read the header of model definition.
The function reads and returns the size of the stream and the dimensions of intermediate and acoustic vectors.
| [in] | numStream | Number of the stream |
| [in] | streamSize | Size of the stream |
| [in] | vecSize | Dimension of an intermediate feature |
| [in] | targetVecSize | Dimension of an acoustic feature |
| [in] | fp | File pointer from which the header is read |
| RTN_ERROR | File read error | |
| NO_ERROR | Successful execution |
| static char * readLabel | ( | char * | line | ) | [static] |
Read a label from a given char array.
| [in] | line | Array of characters |
| NULL | Memory allocation error | |
| otherwise | Pointer to an allocated array for the label |
| static double ** readMapping | ( | FILE * | fp, | |
| int | domainDim, | |||
| int | rangeDim | |||
| ) | [static] |
Read a map matrix.
| [in] | fp | File pointer to the model file |
| [in] | domainDim | Number of columns of the matrix |
| [in] | rangeDim | Number of rows of the matrix |
| NULL | Memory allocation error / File read error | |
| otherwise | Pointer to the matrix |
| static SEG_MAP * readMappings | ( | FILE * | fp | ) | [static] |
Read a set of forward and inverse map matrices.
| [in] | fp | File pointer to the model file |
| NULL | Memory allocation error / File read error | |
| otherwise | Pointer to a mapping information variable of structure segMap (SEG_MAP) |
| static double ** readMatrix | ( | double ** | mat, | |
| FILE * | fp, | |||
| int | nrow, | |||
| int | ncol | |||
| ) | [static] |
Read a matrix from a file stream given.
| [in,out] | mat | Matrix (2-D) |
| [in] | fp | File pointer |
| [in] | nrow | Number of rows of the matrix |
| [in] | ncol | Number of columns of the matrix |
| NULL | File read error | |
| otherwise | Pointer to the matrix |
| static SEG_MDPARAM * readModel | ( | FILE * | fp, | |
| int | maxDur | |||
| ) | [static] |
Read a single model.
| [in] | fp | File pointer from which model parameters are read |
| [in] | maxDur | Maximal segment-duration |
| NULL | Memory allocation/File read error | |
| otherwise | Pointer to a variable of structure modelDef (SEG_MDPARAM) containing the read model parameters |
| static SEG_MODEL_SET * readModelSet | ( | char * | modelList, | |
| int | maxDur | |||
| ) | [static] |
Read a set of multi-level segmental-HMMs in the file of model name list.
| [in] | modelList | Name of file containing model-name list |
| [in] | maxDur | Maximal segment-duration |
| NULL | Memory allocation / File read error | |
| otherwise | Pointer to a read model set |
| static int readParamAccum | ( | double ** | param, | |
| double ** | accum, | |||
| FILE * | fp, | |||
| int | dim | |||
| ) | [static] |
Load a parameter vector from a model file.
Allocate memory for a parameter vector and an accumulator vector, read the parameter vector from a model file, and store the parameter vector in the allocated memory
| [in,out] | param | Pointer to a pointer to an array to be used to store read parameters |
| [in,out] | accum | Pointer to a pointer to an array to be used for accumulators |
| [in] | fp | File pointer to the model file |
| [in] | dim | Dimension of vector of the parameter and accumulator |
| NO_ERROR | Successful execution | |
| RTN_ERROR | Memory allocation error/File read error |
| static double * readParameter | ( | FILE * | fp, | |
| int | dim | |||
| ) | [static] |
Allocate memory space, read a matrix from a file stream given, and store the matrix in the allocated space.
| [in] | fp | File pointer |
| [in] | dim | Dimension of vector |
| NULL | Memory allocation error / File read error | |
| otherwise | Pointer to the allocated space (i.e. the vector) |
Read model parameters of an emitting state.
| [in,out] | state | Model parameters for the state |
| [in] | fp | File pointer of the model file |
| [in] | numDur | Maximum segment-duration |
| NULL | Memory allocation error / File read error | |
| otherwise | Pointer to the model parameter |
| static SEG_TRPROB * readTransProbs | ( | FILE * | fp | ) | [static] |
Read and store a transition probability matrix.
| [in] | fp | File pointer to the model file |
| NULL | Memory allocation error / File read error | |
| otherwise | Pointer to a variable of structure transProb (SEG_TRPROB) |
| static SEG_TRJ * readTrjModel | ( | FILE * | fp | ) | [static] |
Read a trajectory model.
| [in] | fp | File pointer from which the the model is loaded |
| NULL | Memory allocation error / File read error | |
| otherwise | Pointer to a structure (trjModel) variable where the model is stored |
Read and store a variance vector.
| [in,out] | trajModel | Structure variable for the segment trajectory |
| [in] | fp | File pointer |
| [in] | dim | Dimension of the variance vector |
| NULL | Memory allocation error / File read error | |
| otherwise | Pointer to the structure variable (SEG_TRJ) where the vector is stored |
| static double * readVector | ( | double * | vec, | |
| FILE * | fp, | |||
| int | dim | |||
| ) | [static] |
Read a vector from a given file stream.
| [in,out] | vec | Vector |
| [in] | fp | File pointer |
| [in] | dim | Dimension of the vector |
| NULL | File read error | |
| otherwise | Pointer to the vector |
| int segCheckModelSet | ( | SEG_MODEL_SET * | modelset | ) |
Check the consistency of model parameter set.
This function checks if a given model parameter set is consistent in terms of the dimensionality of vectors and matrices.
| [in] | modelset | Pointer to the model-set structure variable |
| NO_ERROR | Successful execution | |
| RTN_ERROR | Inconsistency found in the set |
| int segMakeStrictLRTopology | ( | SEG_MODEL_SET * | modelset | ) |
Force models to maintain strict left-to-right topology.
| [in,out] | modelset | Pointer to the model-set structure variable |
| NO_ERROR | Successful execution |
| SEG_MODEL_SET* segReadModelSet | ( | char * | modelList, | |
| char * | tiedList, | |||
| int | maxDur | |||
| ) |
Read a set of multi-level segmental-HMMs in the file of model name list.
| [in] | modelList | Name of file containing model file name list |
| [in] | tiedList | Name of file containing tied-phone list |
| [in] | maxDur | Maximal segment-duration |
| NULL | Memory allocation/File read error | |
| otherwise | Pointer to a read model set |
| int segWriteDump | ( | SEG_MODEL_SET * | modelset, | |
| char * | fName | |||
| ) |
Write dump file contents.
This function creates a dump file, which includes the label name, maximum segment-duration, the number of states, and duration count and skip count results, for debugging purpose.
| [in] | modelset | Pointer to the model-set structure variable |
| [in] | fName | Name of dump file |
| RTN_ERROR | File open error | |
| NO_ERROR | Successful execution |
| int segWriteModelSet | ( | SEG_MODEL_SET * | modelset, | |
| FILE * | fp | |||
| ) |
Write a set of models to a file.
| [in] | modelset | Pointer to the model-set structure variable |
| [in] | fp | File pointer |
| RTN_ERROR | Memory allocation error / File write error | |
| NO_ERROR | Successful execution |
| static int tieModelParameters | ( | SEG_MODEL_SET * | modelset | ) | [static] |
Tie model parameters.
The function makes pointer-links between model parameters to be tied.
| [in] | modelset | Model set |
| RTN_ERROR | Illegal definitions found in the set | |
| NO_ERROR | Successful execution |
| static int writeMatrix | ( | double ** | mat, | |
| FILE * | fp, | |||
| int | nrow, | |||
| int | ncol | |||
| ) | [static] |
Write a matrix to a file stream given.
| [in] | mat | Matrix (2-D) |
| [in] | fp | File pointer |
| [in] | nrow | Number of rows of the matrix |
| [in] | ncol | Number of columns of the matrix |
| RTN_ERROR | File write error | |
| NO_ERROR | Successful execution |
| static int writeStateInfo | ( | FILE * | fp, | |
| SEG_STATE * | state | |||
| ) | [static] |
Write model parameters for an emitting state.
| [in] | fp | File pointer to which the parameters are written |
| [in] | state | Model parameters for the state |
| RTN_ERROR | File write error | |
| NO_ERROR | Pointer to the model parameter |
| static int writeVector | ( | double * | vec, | |
| FILE * | fp, | |||
| int | dim | |||
| ) | [static] |
Write a vector to a given file stream.
| [in] | vec | Vector |
| [in] | fp | File pointer |
| [in] | dim | Dimension of the vector |
| RTN_ERROR | File write error | |
| NO_ERROR | Successful execution |
1.5.1