void mage_hts_engine_impl::generate_samples(hts_label& lab) { double pitch=lab.get_pitch(); MAGE::FrameQueue* fq=mage->getFrameQueue(); while(!(output->is_stopped()||fq->isEmpty())) { MAGE::Frame* f=fq->get(); std::copy(f->streams[MAGE::mgcStreamIndex],f->streams[MAGE::mgcStreamIndex]+mgc.size(),mgc.begin()); std::copy(f->streams[MAGE::bapStreamIndex],f->streams[MAGE::bapStreamIndex]+ap.size(),ap.begin()); for(int i=0;i<ap.size();++i) { if(ap[i]>0) ap[i]=0; ap[i]=std::pow(10.0,ap[i]/10.0); } double lf0=(f->voiced)?(f->streams[MAGE::lf0StreamIndex][0]):LZERO; if(f->voiced&&(pitch!=1)) { double f0=std::exp(lf0)*pitch; if(f0<20) f0=20; lf0=std::log(f0); } fq->pop(); HTS_Vocoder_synthesize(vocoder.get(),mgc_order,lf0,&(mgc[0]),&(ap[0]),&bpf,alpha,beta,1,&(speech[0]),0); for(int i=0;i<frame_shift;++i) { speech[i]/=32768.0; } output->process(&(speech[0]),frame_shift); } }
void mage_hts_engine_impl::generate_samples(hts_label& lab) { double pitch=lab.get_pitch(); double mgc[MAGE::nOfMGCs]; double* lpf=0; int nlpf=(MAGE::nOfLPFs-1)/2; MAGE::FrameQueue* fq=mage->getFrameQueue(); while(!(output->is_stopped()||fq->isEmpty())) { MAGE::Frame* f=fq->get(); std::copy(f->streams[MAGE::mgcStreamIndex],f->streams[MAGE::mgcStreamIndex]+MAGE::nOfMGCs,mgc); double lf0=(f->voiced)?(f->streams[MAGE::lf0StreamIndex][0]):LZERO; if(f->voiced&&(pitch!=1)) { double f0=std::exp(lf0)*pitch; if(f0<20) f0=20; lf0=std::log(f0); } lpf=f->streams[MAGE::lpfStreamIndex]; fq->pop(); HTS106_Audio audio; audio.data=this; HTS106_Vocoder_synthesize(vocoder.get(),MAGE::nOfMGCs-1,lf0,mgc,nlpf,lpf,MAGE::defaultAlpha,beta,1,0,&audio); } }
void mage_hts_engine_impl::generate_parameters(hts_label& lab) { MAGE::Label mlab(lab.get_name()); if(rate!=1) mlab.setSpeed(rate); if(lab.get_time()==0) { mlab.setEnd(250000); mlab.setDurationForced(true); } mage->setLabel(mlab); mage->prepareModel(); mage->computeDuration(); mage->computeParameters(); mage->optimizeParameters(); }