Exemple #1
0
/* HTS_Engine_generate_state_sequence: genereate state sequence (1st synthesis step) */
static HTS_Boolean HTS_Engine_generate_state_sequence(HTS_Engine * engine)
{
   size_t i, state_index, model_index;
   double f;

   if (HTS_SStreamSet_create(&engine->sss, &engine->ms, &engine->label, engine->condition.phoneme_alignment_flag, engine->condition.speed, engine->condition.duration_iw, engine->condition.parameter_iw, engine->condition.gv_iw) != TRUE) {
      HTS_Engine_refresh(engine);
      return FALSE;
   }
   if (engine->condition.additional_half_tone != 0.0) {
      state_index = 0;
      model_index = 0;
      for (i = 0; i < HTS_Engine_get_total_state(engine); i++) {
         f = HTS_Engine_get_state_mean(engine, 1, i, 0);
         f += engine->condition.additional_half_tone * HALF_TONE;
         if (f < MIN_LF0)
            f = MIN_LF0;
         else if (f > MAX_LF0)
            f = MAX_LF0;
         HTS_Engine_set_state_mean(engine, 1, i, 0, f);
         state_index++;
         if (state_index >= HTS_Engine_get_nstate(engine)) {
            state_index = 0;
            model_index++;
         }
      }
   }
   return TRUE;
}
Exemple #2
0
/* HTS_Engine_synthesize_from_strings: synthesize speech from strings */
HTS_Boolean HTS_Engine_synthesize_from_strings(HTS_Engine * engine, char **lines, size_t num_lines)
{
   size_t i;
   double f;

   HTS_Engine_refresh(engine);
// Generate state sequence
   if (HTS_SStreamSet_create(&engine->sss, &engine->ms, lines, num_lines, engine->condition.speed) != TRUE) {
      HTS_Engine_refresh(engine);
      return FALSE;
   }
   if (engine->condition.additional_half_tone != 0.0) {
      for (i = 0; i < HTS_SStreamSet_get_total_state(&engine->sss); i++) {
         f = HTS_SStreamSet_get_mean(&engine->sss, 1, i, 0);
         f += engine->condition.additional_half_tone * HALF_TONE;
         if (f < MIN_LF0)
            f = MIN_LF0;
         else if (f > MAX_LF0)
            f = MAX_LF0;
         HTS_SStreamSet_set_mean(&engine->sss, 1, i, 0, f);
      }
   }
// Generate parameter sequence
   if (HTS_PStreamSet_create(&engine->pss, &engine->sss, engine->condition.msd_threshold) != TRUE) {
      HTS_Engine_refresh(engine);
      return FALSE;
   }

// Free state sequence
   HTS_SStreamSet_clear(&engine->sss);

// Generate sound sample sequence
   if (HTS_GStreamSet_create(&engine->gss, &engine->pss, engine->condition.sampling_frequency,
                             engine->condition.fperiod, engine->condition.alpha,
                             engine->condition.beta) != TRUE) {
      HTS_Engine_refresh(engine);
      return FALSE;
   }
   return TRUE;
}
/* HTS_Engine_create_sstream: parse label and determine state duration */
void HTS_Engine_create_sstream(HTS_Engine * engine)
{
    HTS_SStreamSet_create(&engine->sss, &engine->ms, &engine->label,
                          engine->global.duration_iw,
                          engine->global.parameter_iw, engine->global.gv_iw);
}