[Subject Prev][Subject Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hts-users:01455] gstream redundancy


Hi,

Is there some reason for duplicating pstream data to gstream data?
Meaning that we could reduce memory consumption and time spend of making
duplicates by removing gstreams and writing HTS_GStreamSet_create() simply
as shown below. (I use pss->total_frame instead of the API function etc,
but that is trivial.)

br,
  Nicholas



/* HTS_GStreamSet_create: generate speech */
/* (stream[0] == spectrum && stream[1] == lf0) */
void HTS_GStreamSet_create(HTS_GStreamSet * gss, HTS_PStreamSet * pss,
                           int stage, int sampling_rate, int fperiod,
                           double alpha, double beta, int audio_buff_size) {
   int i, j, k;

   int msd_frame;
   HTS_Vocoder v;

   /* check */
   if ( gss->gspeech )
     HTS_error(1, "HTS_GStreamSet_create: HTS_GStreamSet has to
initialize.");

   /* initialize */
   gss->total_nsample = fperiod * pss->total_frame;

   /* check */
   if (pss->nstream != 2)
      HTS_error(1, "HTS_GStreamSet_create: nstream != 2 is not support.");
   if (pss->pstream[1].static_length != 1)
      HTS_error(1,
                "HTS_GStreamSet_create: lf0 static vector size != 1 is not
support.");

   gss->gspeech = (short *) HTS_calloc(gss->total_nsample, sizeof(short));

   /* synthesize speech waveform */
   HTS_Vocoder_initialize(&v, pss->pstream[0].static_length - 1, stage,
                          sampling_rate, fperiod, audio_buff_size);
   for (i = 0, msd_frame=0; i < pss->total_frame; i++) {
     double lf0 = LZERO;
     if ( pss->pstream[1].msd_flag[i] ) {
       lf0 = pss->pstream[1].par[msd_frame++][0];
     }
     HTS_Vocoder_synthesize(&v, pss->pstream[0].static_length - 1,
			    lf0,
			    &pss->pstream[0].par[i][0], alpha, beta,
			    &gss->gspeech[i * fperiod]);
   }
   HTS_Vocoder_clear(&v);
}

Ok, I use /* HTS_GStreamSet_create: generate speech */
/* (stream[0] == spectrum && stream[1] == lf0) */
void HTS_GStreamSet_create(HTS_GStreamSet * gss, HTS_PStreamSet * pss,
                           int stage, int sampling_rate, int fperiod,
                           double alpha, double beta, int audio_buff_size) {
   int i, j, k;

   int msd_frame;
   HTS_Vocoder v;

   /* check */
   if ( gss->gspeech )
     HTS_error(1, "HTS_GStreamSet_create: HTS_GStreamSet has to
initialize.");

   /* initialize */
   gss->total_nsample = fperiod * pss->total_frame;

   /* check */
   if (pss->nstream != 2)
      HTS_error(1, "HTS_GStreamSet_create: nstream != 2 is not support.");
   if (pss->pstream[1].static_length != 1)
      HTS_error(1,
                "HTS_GStreamSet_create: lf0 static vector size != 1 is not
support.");

   gss->gspeech = (short *) HTS_calloc(gss->total_nsample, sizeof(short));

   /* synthesize speech waveform */
   HTS_Vocoder_initialize(&v, pss->pstream[0].static_length - 1, stage,
                          sampling_rate, fperiod, audio_buff_size);
   for (i = 0, msd_frame=0; i < pss->total_frame; i++) {
     double lf0 = LZERO;
     if ( pss->pstream[1].msd_flag[i] ) {
       lf0 = pss->pstream[1].par[msd_frame++][0];
     }
     HTS_Vocoder_synthesize(&v, pss->pstream[0].static_length - 1,
			    lf0,
			    &pss->pstream[0].par[i][0], alpha, beta,
			    &gss->gspeech[i * fperiod]);
   }
   HTS_Vocoder_clear(&v);
}





Follow-Ups
[hts-users:01456] Re: gstream redundancy, Heiga ZEN (Byung Ha CHUN)