// file: dec_sil_0.cc
//

// isip include files
//
#include "decoder.h"
#include "decoder_constants.h"
 
static int_4* trans_states = (int_4*)NULL;
static float_4* trans_scores = (float_4*)NULL;
static int_4 trans_states_size = 0;

// method: find_sp_cc
//
// arguments: none
//
// return: logical_1 indicating status
//
// this method finds the short pause model index and sets the sp skip
// transition score
//
logical_1 Decoder::find_sp_cc() {
  
  // create the sp phone
  //
  int_4* phn = new int_4[cd_size_d];

  // if this is a context dependent mode create sp triphone
  //
  if (context_mode_d != DEC_MONO_PHONE_MODE) {
    phn[0] = (int_4)0;
    phn[1] = DEC_SP_PHONE;
    phn[2] = (int_4)0;
  }

  // otherwise use the monophone
  //
  else {
    phn[0] = DEC_SP_PHONE;
  }
  
  // get the model index
  //
  sp_model_d = get_model_index_cc(phn);

  // free memory
  //
  delete [] phn;
  phn = (int_4*)NULL;
  
  // get the model params
  //
  Model* model = cd_models_d[sp_model_d]->get_model_cc();
  int_4 num_st = model->get_num_states_cc();
  
  // temp variables
  //
  int_4 ntrans = (int_4)0;
  
  // find all possible start states for this phone
  //
  model->get_next_states_cc((int_4)0, ntrans, trans_states, trans_scores,
			    trans_states_size);
  
  // get the transition score to exit state
  //
  for (int_4 kk = 0; kk < ntrans; kk++) {
    
    // check for stop state
    //
    if (trans_states[kk] == num_st - (int_4)1) {
      sp_score_d = (float_4)trans_scores[kk];
      break;
    }
  }

  // exit gracefully
  //
  return ISIP_TRUE;
}
