/**************************************************************************/ /* File: hmm_model.cc */ /**************************************************************************/ /* Project: Continuous Speech Recognition Search Algorithms */ /* Author: Neeraj Deshmukh, Aravind Ganapathiraju */ /* Class: EE 8993 Spring 1996 Date: April 1, 1996 */ /**************************************************************************/ /*======================================================================== This file defines the HMM class methods that model the various phonemes (triphones) for the EE 8993 speech recognizer ========================================================================*/ /*------------------------------------------------------------------------ system and ISIP include files ------------------------------------------------------------------------*/ #include "hmm_model.h" #include "hmm_state.h" #include "hmm_matrix.h" /*------------------------------------------------------------------------ forward declaration of classes ------------------------------------------------------------------------*/ class HMM_Model; class HMM_State; class HMM_Matrix; class HMM_Trans_State; /*------------------------------------------------------------------------ Constructors and Destructors ------------------------------------------------------------------------*/ // create hmm, initialize model parameters from file. // HMM_Model :: HMM_Model ( String model_symbol_l, int_2 num_of_states_l) { num_of_states_d = num_of_states_l; states = new HMM_State (); model_symbol_d = model_symbol_l; } // destructor // HMM_Model :: ~HMM_Model () { // free memory // delete states; delete model_symbol_d; } /*------------------------------------------- I/O methods -------------------------------------------*/ // set the model output symbol to the specified character // void HMM_Model :: set_model_symbol_cc ( String model_symbol_l ) { // free memory asociated with old string // delete [] model_symbol_d; // allot appropriate memory block // model_symbol_d = new char[strlen (model_symbol_l) + 1]; // now copy string over // strcpy (model_symbol_d, model_symbol_l); } // get the model output symbol // String HMM_Model :: get_model_symbol_cc () { return (model_symbol_d); } //set the number of states in the model // void HMM_Model :: set_num_of_states_cc ( int_2 num_of_states_l ) { num_of_states_d = num_of_states_l; } // get the score of a specified transition // float_8 HMM_Model :: get_trans_score_cc (String from_state_name, String to_state_name ) { HMM_State *curr_state= states->find_state_cc( from_state_name ); return (curr_state->get_trans_prob_cc ( to_state_name )); } // add a new state to existing list of states in the model // HMM_State *HMM_Model::add_state_cc ( String state_name ) { return ( states->add_state_cc (state_name) ); } // get the states of the model // HMM_State *HMM_Model :: get_states_cc () { return ( states ); } // get the start state of the model // HMM_State *HMM_Model :: get_start_state_cc () { HMM_State *temp_state; for ( temp_state = states->get_next_state_cc (); temp_state->get_next_state_cc () != NULL; temp_state = temp_state->get_next_state_cc ()) { } return (temp_state); } // get the stop state of the model // HMM_State *HMM_Model :: get_stop_state_cc () { return (states->get_next_state_cc ()); }