Пример #1
0
/* HTS_ModelSet_get_gv_index: get index of GV tree and PDF */
void HTS_ModelSet_get_gv_index(HTS_ModelSet * ms, char *string, int *tree_index,
                               int *pdf_index, int stream_index,
                               int interpolation_index)
{
   HTS_Tree *tree;
   HTS_Pattern *pattern;
   HTS_Boolean find;

   find = FALSE;
   (*tree_index) = 2;
   (*pdf_index) = 1;

   if (HTS_ModelSet_have_gv_tree(ms, stream_index) == FALSE)
      return;
   for (tree = ms->gv[stream_index].model[interpolation_index].tree; tree;
        tree = tree->next) {
      pattern = tree->head;
      if (!pattern)
         find = TRUE;
      for (; pattern; pattern = pattern->next)
         if (HTS_pattern_match(string, pattern->string)) {
            find = TRUE;
            break;
         }
      if (find)
         break;
      (*tree_index)++;
   }

   if (tree == NULL)
      HTS_error(1, "HTS_ModelSet_get_gv_index: Cannot find model %s.\n",
                string);
   (*pdf_index) = HTS_Tree_search_node(tree, string);
}
Пример #2
0
/* HTS_Engine_save_information: output trace information */
void HTS_Engine_save_information(HTS_Engine * engine, FILE * fp)
{
    int i, j, k, l, m, n;
    double temp;
    HTS_Global *global = &engine->global;
    HTS_ModelSet *ms = &engine->ms;
    HTS_Label *label = &engine->label;
    HTS_SStreamSet *sss = &engine->sss;
    HTS_PStreamSet *pss = &engine->pss;

    /* global parameter */
    fprintf(fp, "[Global parameter]\n");
    fprintf(fp, "Sampring frequency                     -> %8d(Hz)\n",
            global->sampling_rate);
    fprintf(fp, "Frame period                           -> %8d(point)\n",
            global->fperiod);
    fprintf(fp, "                                          %8.5f(msec)\n",
            1e+3 * global->fperiod / global->sampling_rate);
    fprintf(fp, "All-pass constant                      -> %8.5f\n",
            (float) global->alpha);
    fprintf(fp, "Gamma                                  -> %8.5f\n",
            (float) (global->stage == 0 ? 0.0 : -1.0 / global->stage));
    if (global->stage != 0)
        fprintf(fp, "Log gain flag                          -> %s\n",
                global->use_log_gain ? "TRUE" : "FALSE");
    fprintf(fp, "Postfiltering coefficient              -> %8.5f\n",
            (float) global->beta);
    fprintf(fp, "Audio buffer size                      -> %8d(sample)\n",
            global->audio_buff_size);
    fprintf(fp, "\n");

    /* duration parameter */
    fprintf(fp, "[Duration parameter]\n");
    fprintf(fp, "Number of states                       -> %8d\n",
            HTS_ModelSet_get_nstate(ms));
    fprintf(fp, "         Interpolation                 -> %8d\n",
            HTS_ModelSet_get_duration_interpolation_size(ms));
    /* check interpolation */
    for (i = 0, temp = 0.0;
            i < HTS_ModelSet_get_duration_interpolation_size(ms); i++)
        temp += global->duration_iw[i];
    for (i = 0; i < HTS_ModelSet_get_duration_interpolation_size(ms); i++)
        if (global->duration_iw[i] != 0.0)
            global->duration_iw[i] /= temp;
    for (i = 0; i < HTS_ModelSet_get_duration_interpolation_size(ms); i++)
        fprintf(fp,
                "         Interpolation weight[%2d]      -> %8.0f(%%)\n", i,
                (float) (100 * global->duration_iw[i]));
    fprintf(fp, "\n");

    fprintf(fp, "[Stream parameter]\n");
    for (i = 0; i < HTS_ModelSet_get_nstream(ms); i++) {
        /* stream parameter */
        fprintf(fp, "Stream[%2d] vector length               -> %8d\n", i,
                HTS_ModelSet_get_vector_length(ms, i));
        fprintf(fp, "           Dynamic window size         -> %8d\n",
                HTS_ModelSet_get_window_size(ms, i));
        /* interpolation */
        fprintf(fp, "           Interpolation               -> %8d\n",
                HTS_ModelSet_get_parameter_interpolation_size(ms, i));
        for (j = 0, temp = 0.0;
                j < HTS_ModelSet_get_parameter_interpolation_size(ms, i); j++)
            temp += global->parameter_iw[i][j];
        for (j = 0; j < HTS_ModelSet_get_parameter_interpolation_size(ms, i); j++)
            if (global->parameter_iw[i][j] != 0.0)
                global->parameter_iw[i][j] /= temp;
        for (j = 0; j < HTS_ModelSet_get_parameter_interpolation_size(ms, i); j++)
            fprintf(fp,
                    "           Interpolation weight[%2d]    -> %8.0f(%%)\n", j,
                    (float) (100 * global->parameter_iw[i][j]));
        /* MSD */
        if (HTS_ModelSet_is_msd(ms, i)) { /* for MSD */
            fprintf(fp, "           MSD flag                    ->     TRUE\n");
            fprintf(fp, "           MSD threshold               -> %8.5f\n",
                    global->msd_threshold[i]);
        } else {                  /* for non MSD */
            fprintf(fp, "           MSD flag                    ->    FALSE\n");
        }
        /* GV */
        if (HTS_ModelSet_use_gv(ms, i)) {
            fprintf(fp, "           GV flag                     ->     TRUE\n");
            if (HTS_ModelSet_have_gv_switch(ms)) {
                if (HTS_ModelSet_have_gv_tree(ms, i)) {
                    fprintf(fp,
                            "           GV type                     ->     CDGV\n");
                    fprintf(fp,
                            "                                       ->  +SWITCH\n");
                } else
                    fprintf(fp,
                            "           GV type                     ->   SWITCH\n");
            } else {
                if (HTS_ModelSet_have_gv_tree(ms, i))
                    fprintf(fp,
                            "           GV type                     ->     CDGV\n");
                else
                    fprintf(fp,
                            "           GV type                     ->   NORMAL\n");
            }
            fprintf(fp, "           GV weight                   -> %8.0f(%%)\n",
                    (float) (100 * global->gv_weight[i]));
            fprintf(fp, "           GV interpolation size       -> %8d\n",
                    HTS_ModelSet_get_gv_interpolation_size(ms, i));
            /* interpolation */
            for (j = 0, temp = 0.0;
                    j < HTS_ModelSet_get_gv_interpolation_size(ms, i); j++)
                temp += global->gv_iw[i][j];
            for (j = 0; j < HTS_ModelSet_get_gv_interpolation_size(ms, i); j++)
                if (global->gv_iw[i][j] != 0.0)
                    global->gv_iw[i][j] /= temp;
            for (j = 0; j < HTS_ModelSet_get_gv_interpolation_size(ms, i); j++)
                fprintf(fp,
                        "           GV interpolation weight[%2d] -> %8.0f(%%)\n", j,
                        (float) (100 * global->gv_iw[i][j]));
        } else {
            fprintf(fp, "           GV flag                     ->    FALSE\n");
        }
    }
    fprintf(fp, "\n");

    /* generated sequence */
    fprintf(fp, "[Generated sequence]\n");
    fprintf(fp, "Number of HMMs                         -> %8d\n",
            HTS_Label_get_size(label));
    fprintf(fp, "Number of stats                        -> %8d\n",
            HTS_Label_get_size(label) * HTS_ModelSet_get_nstate(ms));
    fprintf(fp, "Length of this speech                  -> %8.3f(sec)\n",
            (float) ((double) HTS_PStreamSet_get_total_frame(pss) *
                     global->fperiod / global->sampling_rate));
    fprintf(fp, "                                       -> %8.3d(frames)\n",
            HTS_PStreamSet_get_total_frame(pss) * global->fperiod);

    for (i = 0; i < HTS_Label_get_size(label); i++) {
        fprintf(fp, "HMM[%2d]\n", i);
        fprintf(fp, "  Name                                 -> %s\n",
                HTS_Label_get_string(label, i));
        fprintf(fp, "  Duration\n");
        for (j = 0; j < HTS_ModelSet_get_duration_interpolation_size(ms); j++) {
            fprintf(fp, "    Interpolation[%2d]\n", j);
            HTS_ModelSet_get_duration_index(ms, HTS_Label_get_string(label, i), &k,
                                            &l, j);
            fprintf(fp, "      Tree index                       -> %8d\n", k);
            fprintf(fp, "      PDF index                        -> %8d\n", l);
        }
        for (j = 0; j < HTS_ModelSet_get_nstate(ms); j++) {
            fprintf(fp, "  State[%2d]\n", j + 2);
            fprintf(fp, "    Length                             -> %8d(frames)\n",
                    HTS_SStreamSet_get_duration(sss,
                                                i * HTS_ModelSet_get_nstate(ms) +
                                                j));
            for (k = 0; k < HTS_ModelSet_get_nstream(ms); k++) {
                fprintf(fp, "    Stream[%2d]\n", k);
                if (HTS_ModelSet_is_msd(ms, k)) {
                    if (HTS_SStreamSet_get_msd
                            (sss, k,
                             i * HTS_ModelSet_get_nstate(ms) + j) >
                            global->msd_threshold[k])
                        fprintf(fp,
                                "      MSD flag                         ->     TRUE\n");
                    else
                        fprintf(fp,
                                "      MSD flag                         ->    FALSE\n");
                }
                for (l = 0;
                        l < HTS_ModelSet_get_parameter_interpolation_size(ms, k);
                        l++) {
                    fprintf(fp, "      Interpolation[%2d]\n", l);
                    HTS_ModelSet_get_parameter_index(ms,
                                                     HTS_Label_get_string(label, i),
                                                     &m, &n, k, j + 2, l);
                    fprintf(fp, "        Tree index                     -> %8d\n",
                            m);
                    fprintf(fp, "        PDF index                      -> %8d\n",
                            n);
                }
            }
        }
    }
}