/* HTS_ModelSet_load_parameter: load model */ void HTS_ModelSet_load_parameter(HTS_ModelSet * ms, FILE ** pdf_fp, FILE ** tree_fp, FILE ** win_fp, int stream_index, HTS_Boolean msd_flag, int window_size, int interpolation_size) { int i; /* check */ if (pdf_fp == NULL) HTS_error(1, "HTS_ModelSet_load_parameter: File for pdfs is not specified.\n"); if (tree_fp == NULL) HTS_error(1, "HTS_ModelSet_load_parameter: File for wins is not specified.\n"); if (win_fp == NULL) HTS_error(1, "HTS_ModelSet_load_parameter: File for wins is not specified.\n"); /* initialize */ if (!ms->stream) { ms->stream = (HTS_Stream *) HTS_calloc(ms->nstream, sizeof(HTS_Stream)); for (i = 0; i < ms->nstream; i++) HTS_Stream_initialize(&ms->stream[i]); } /* load */ HTS_Stream_load_pdf_and_tree(&ms->stream[stream_index], pdf_fp, tree_fp, msd_flag, interpolation_size); HTS_Stream_load_dynamic_window(&ms->stream[stream_index], win_fp, window_size); }
/* HTS_ModelSet_initialize: initialize model set */ void HTS_ModelSet_initialize(HTS_ModelSet * ms, int nstream) { HTS_Stream_initialize(&ms->duration); ms->stream = NULL; ms->gv = NULL; HTS_Model_initialize(&ms->gv_switch); ms->nstate = -1; ms->nstream = nstream; }
/* HTS_Stream_clear: free stream */ static void HTS_Stream_clear(HTS_Stream * stream) { int i; if (stream->model) { for (i = 0; i < stream->interpolation_size; i++) HTS_Model_clear(&stream->model[i]); HTS_free(stream->model); } HTS_Window_clear(&stream->window); HTS_Stream_initialize(stream); }
/* HTS_ModelSet_load_parameter: load model */ HTS_Boolean HTS_ModelSet_load_parameter(HTS_ModelSet * ms, HTS_File ** pdf_fp, HTS_File ** tree_fp, HTS_File ** win_fp, int stream_index, int window_size, int interpolation_size) { int i; /* check */ if (ms == NULL) { return FALSE; } if (stream_index < 0 || stream_index >= ms->nstream || window_size <= 0 || interpolation_size <= 0) { HTS_ModelSet_clear(ms); return FALSE; } if (pdf_fp == NULL) { HTS_error(1, "HTS_ModelSet_load_parameter: File for pdfs is not specified.\n"); HTS_ModelSet_clear(ms); return FALSE; } if (tree_fp == NULL) { HTS_error(1, "HTS_ModelSet_load_parameter: File for wins is not specified.\n"); HTS_ModelSet_clear(ms); return FALSE; } if (win_fp == NULL) { HTS_error(1, "HTS_ModelSet_load_parameter: File for wins is not specified.\n"); HTS_ModelSet_clear(ms); return FALSE; } /* initialize */ if (!ms->stream) { ms->stream = (HTS_Stream *) HTS_calloc(ms->nstream, sizeof(HTS_Stream)); for (i = 0; i < ms->nstream; i++) HTS_Stream_initialize(&ms->stream[i]); } /* load */ if (HTS_Stream_load_pdf_and_tree(&ms->stream[stream_index], pdf_fp, tree_fp, interpolation_size) == FALSE) { HTS_ModelSet_clear(ms); return FALSE; } if (HTS_Stream_load_dynamic_window(&ms->stream[stream_index], win_fp, window_size) == FALSE) { HTS_ModelSet_clear(ms); return FALSE; } return TRUE; }
/* HTS_ModelSet_load_gv: load GV model */ void HTS_ModelSet_load_gv(HTS_ModelSet * ms, FILE ** pdf_fp, FILE ** tree_fp, int stream_index, int interpolation_size) { int i; /* check */ if (pdf_fp == NULL) HTS_error(1, "HTS_ModelSet_load_gv: File for GV pdfs is not specified.\n"); /* initialize */ if (!ms->gv) { ms->gv = (HTS_Stream *) HTS_calloc(ms->nstream, sizeof(HTS_Stream)); for (i = 0; i < ms->nstream; i++) HTS_Stream_initialize(&ms->gv[i]); } if (tree_fp) HTS_Stream_load_pdf_and_tree(&ms->gv[stream_index], pdf_fp, tree_fp, FALSE, interpolation_size); else HTS_Stream_load_pdf(&ms->gv[stream_index], pdf_fp, 1, FALSE, interpolation_size); }
/* HTS_ModelSet_load_gv: load GV model */ HTS_Boolean HTS_ModelSet_load_gv(HTS_ModelSet * ms, HTS_File ** pdf_fp, HTS_File ** tree_fp, int stream_index, int interpolation_size) { int i; /* check */ if (ms == NULL) { return FALSE; } if (stream_index < 0 || stream_index >= ms->nstream || interpolation_size <= 0) { HTS_ModelSet_clear(ms); return FALSE; } if (pdf_fp == NULL) { HTS_error(1, "HTS_ModelSet_load_gv: File for GV pdfs is not specified.\n"); HTS_ModelSet_clear(ms); return FALSE; } /* initialize */ if (!ms->gv) { ms->gv = (HTS_Stream *) HTS_calloc(ms->nstream, sizeof(HTS_Stream)); for (i = 0; i < ms->nstream; i++) HTS_Stream_initialize(&ms->gv[i]); } if (tree_fp) { if (HTS_Stream_load_pdf_and_tree(&ms->gv[stream_index], pdf_fp, tree_fp, interpolation_size) == FALSE) { HTS_ModelSet_clear(ms); return FALSE; } } else { if (HTS_Stream_load_pdf(&ms->gv[stream_index], pdf_fp, 1, interpolation_size) == FALSE) { HTS_ModelSet_clear(ms); return FALSE; } } return TRUE; }