Main Page   Compound List   File List   Compound Members   File Members   Related Pages  

phrase Class Reference

the phrase is the overall entity. More...

#include <phrase.h>

Collaboration diagram for phrase:

Collaboration graph

[legend]
List of all members.

Public Methods

uint MeanF0 ()
 returns the mean val of all f0Vals. More...

void calcMeanF0 ()
 calculates the mean val of all f0Vals. More...

double F0Range ()
 returns range of f0Vals in SemiTones. More...

void printSyllableVec (ostream &outFile)
 prints names of phones to outFile (debugging). More...

void readPhoFile (istream &inFile, globalsT &kg)
 reads in phones for syllables from inFile. More...

void readPhoList (istream &inFile, globalsT &kg)
 assignes only names of phones and syllable borders. More...

void readF0FromDB (string diphonBase, globalsT &glob)
 assignes only f0-vals. More...

void readPhonData (string diphonBase, globalsT &glob)
 reads in amplitudes, formantfreqs and formantbandwidths from diphon-database. More...

void modelKlattParameters (globalsT &glob)
 model voice-source and articulation-tract filter parameters for each phone for normal voice. More...

void modelFeatures (globalsT &kg)
 model voice-source and articulation-tract filter parameters for each phone according to it's assigned features. More...

void printPhonMeanF0 (ostream &outFile)
 prints means of f0-contour per phon to outFile (debugging). More...

void printPhonFeatures (ostream &outFile)
 prints phonfeatures to outFile (debugging). More...

void printPhoFile (ostream &outFile, globalsT glob)
 prints pho-file (mbrola-format). More...

void printLabelFile (ostream &outFile, globalsT globals)
 prints label-file (esps-format). More...

void printKlattFile (ostream &outFile)
 prints klatt-file (iles&simmons-format). More...

void printSenSynFile (globalsT globals, ostream &outFile)
 prints klatt-file (sensymetrics-format). More...

void makeTest (globalsT globals, uint dur)
 fill a phrase with one syllable with one phone of duration dur (in msec) with parameters taken from globals. More...

void changeSpeechRate (uint rate, globalsT globals, int method)
 changes duration of all phones. More...

void changeDurStressed (uint rate, uint both, globalsT globals)
 change duration of stressed syllables. More...

void changeDurNonStressed (uint rate, uint both, globalsT globals)
 change duration of unstressed syllables. More...

void changeDurManner (PHON_MANNER manner, uint rate, globalsT globals)
 change duration of specified phone-manners. More...

void changeStressedInt (int dBVal, uint both, globalsT globals)
 change intensity of stressed syllables. More...

void changeMeanF0 (uint rate, globalsT glob)
 all nonzero f0Vals get multiplied by <rate> in percent. More...

void smootheF0 (uint winsize, globalsT glob)
 smoothing function: all f0Vals get centerFiltered around winsize. More...

void changeStressedAvrF0 (uint rate, uint both, globalsT glob)
 change mean pitch of stressed syllables. More...

void changePreStressedAvrF0 (uint rate, uint both, globalsT glob)
 change avr pitch of the syllables before stressed syllables. More...

void changeF0Range (uint rate, globalsT glob)
 changes the F0-range of phrase. More...

void changeVariability (uint rate, globalsT glob)
 changes the F0-variability. More...

void changePitchContourStressed (CONTOUR_TYPE contour, uint gradient, uint both, globalsT glob)
 changes pitch-contour of stressed syllables to <contour>. More...

void changeLastSylContour (CONTOUR_TYPE contour, uint gradient, globalsT glob)
 changes pitch-contour of last syllable to <contour>. More...

void changePhraseContour (CONTOUR_TYPE contour, uint rate, globalsT glob)
 changes pitch-contour of whole phrase to <contour>. More...

void changePhraseContourToAccent (uint rate, globalsT glob)
 changes pitch-contour of regions of phrase divided by phraseaccents to <contour>. More...

void addWave (uint accRate, uint nonAccRate, uint method, globalsT glob)
 The intonation-contour gets changed according to the wave-model. More...

void overshootVowels (ACCENT_TYPE accent, uint rate, globalsT glob)
 enhance the vowel precision. More...

void undershootVowels (ACCENT_TYPE accent, uint rate, globalsT glob)
 blur the vowel precision. More...

void spread (uint rate, globalsT glob)
 adds spread Lips characteristices. More...

void rounded (uint rate, globalsT glob)
 adds rounded Lips characteristices. More...

void headSize (uint rate, globalsT glob)
 experiment: shift formant-values to model different head-sizes. More...

void coarticulation (uint rate, CO_TYPE coType, globalsT glob)
 model coarticulation effects. More...

void assimilateConsonants (globalsT glob)
 should model assimilation of voicing. More...

void addJitter (ACCENT_TYPE accent, uint rate, uint method, globalsT glob)
 add Jitter (F0-Flutter). More...

void addBreathy (uint rate, globalsT glob)
 simulates breathy phonation at all vowels. More...

void addTense (uint rate, globalsT glob)
 simulates tense phonation at all vowels. More...

void addWhisper (uint rate, globalsT glob)
 simulates whispery phonation at all vowels. More...

void addLaryngealized (uint rate, globalsT glob)
 simulates laryngealization (creaky voice) at first half of vowels after unvoiced sounds. More...

void addCreaky (uint rate, globalsT glob)
 simulates creaky phonation at all vowels. More...

void addFalsett (uint rate, globalsT glob)
 simulates falsetto phonation at all vowels. More...


Private Methods

void calcDur ()

Private Attributes

vector<syllablesyllableVec
uint meanF0
uint dur

Detailed Description

the phrase is the overall entity.

It consists of a list of syllable . All changes made are initiated by phrase. The methods can be categorized into


Member Function Documentation

double phrase::F0Range ( )
 

returns range of f0Vals in SemiTones.

Returns:
double f0range
00048                        {
00049   uint minf0=A_HIGH_INT, maxf0=0;
00050   for (uint syl=0; syl<syllableVec.size(); syl++) {
00051     for (uint pho=0; pho<syllableVec[syl].PhonVec().size(); pho++) { 
00052       if (syllableVec[syl].PhonVec()[pho].Voiced()) {
00053         for (uint f0v=0; f0v<syllableVec[syl].PhonVec()[pho].F0Vec().size(); f0v++) {
00054           if (minf0 > syllableVec[syl].PhonVec()[pho].F0Vec()[f0v] &&
00055               syllableVec[syl].PhonVec()[pho].F0Vec()[f0v]>0)
00056             minf0 = syllableVec[syl].PhonVec()[pho].F0Vec()[f0v];
00057           if (maxf0 < syllableVec[syl].PhonVec()[pho].F0Vec()[f0v])
00058             maxf0 = syllableVec[syl].PhonVec()[pho].F0Vec()[f0v];         
00059         }
00060       }
00061     }
00062   }
00063   return Hz2ST(minf0, maxf0); 
00064 }

uint phrase::MeanF0 ( )
 

returns the mean val of all f0Vals.

Returns:
uint mean
00026                     {
00027   calcMeanF0();
00028   return meanF0;
00029 }

void phrase::addBreathy ( uint rate,
globalsT glob )
 

simulates breathy phonation at all vowels.

Parameters:
uint   rate
globalsT   glob, defaultparams for klattsynth
01507                                                 {
01508   phon *pP;
01509   if (rate > 100)
01510     error("phrase::addBreathy: rate>100\n",-5);
01511   for (uint syl=0; syl<syllableVec.size(); syl++) {
01512     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01513       pP = &syllableVec[syl].PhonVec()[pho];
01514       // if ((*pP).Voiced() && (*pP).Manner()!=stop_voiced && (*pP).Name()!="h") {
01515       if ((*pP).Type() == vowel || (*pP).Manner() == nasal) {
01516         PHON_FEATURES tmpPhonFeatures= (*pP).PhonFeatures();
01517         tmpPhonFeatures.breathy = true;
01518         tmpPhonFeatures.brtStart = 0;
01519         tmpPhonFeatures.brtStop = (*pP).FrameNum();          
01520         tmpPhonFeatures.brtRate = rate;
01521         (*pP).setPhonFeatures(tmpPhonFeatures);
01522       }
01523     }
01524   }
01525   if(glob.verbose)
01526     cerr << "added breathy voice with rate: "<<rate<<"\n";
01527 }

void phrase::addCreaky ( uint rate,
globalsT glob )
 

simulates creaky phonation at all vowels.

Parameters:
uint   rate
globalsT   glob, defaultparams for klattsynth
01619                                                {
01620   phon *pP;
01621   if (rate > 100)
01622     error("phrase::addCreaky: rate>100\n",-5);
01623   for (uint syl=0; syl<syllableVec.size(); syl++) {
01624     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01625       pP = &syllableVec[syl].PhonVec()[pho];
01626       if ((*pP).Voiced()) {
01627         PHON_FEATURES tmpPhonFeatures= (*pP).PhonFeatures();
01628         tmpPhonFeatures.creaky = true;
01629         tmpPhonFeatures.creakyStart = 0;
01630         tmpPhonFeatures.creakyStop = (*pP).FrameNum();       
01631         tmpPhonFeatures.creakyRate = rate;
01632         (*pP).setPhonFeatures(tmpPhonFeatures);
01633       }
01634     }
01635   }
01636   calcMeanF0();
01637   if (glob.verbose)
01638     cerr << "added creaky voice at rate "<<rate<<" \n"; 
01639 }

void phrase::addFalsett ( uint rate,
globalsT glob )
 

simulates falsetto phonation at all vowels.

Parameters:
uint   rate
globalsT   glob, defaultparams for klattsynth
01648                                                 {
01649   phon *pP;
01650   if (rate > 100)
01651     error("phrase::addFalsett: rate>100\n",-5);
01652   for (uint syl=0; syl<syllableVec.size(); syl++) {
01653     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01654       pP = &syllableVec[syl].PhonVec()[pho];
01655       if ((*pP).Voiced()) {
01656         PHON_FEATURES tmpPhonFeatures= (*pP).PhonFeatures();
01657         tmpPhonFeatures.falsett = true;
01658         tmpPhonFeatures.falsettRate = rate;
01659         (*pP).setPhonFeatures(tmpPhonFeatures);
01660       }
01661     }
01662   }
01663   calcMeanF0();
01664   if (glob.verbose)
01665     cerr << "added falsett voice at rate "<<rate<<" \n"; 
01666 }

void phrase::addJitter ( ACCENT_TYPE accent,
uint rate,
uint method,
globalsT glob )
 

add Jitter (F0-Flutter).

Simulates Jitter at all voiced phones in syllables with stress-type=accent. If method = 1, all nonzero f0Vals get displaced about rate alternating down and up. (0 > rate < 10) If method = 2, the klattSyn parameter skew/FL is set to rate (0 > rate < 300)

Parameters:
ACCENT_TYPE   stress type of affected syllables
uint   rate
globalsT   glob, defaultparams for klattsynth
01481                                                                                 {
01482   phon *pP;
01483   for (uint syl=0; syl<syllableVec.size(); syl++) {
01484     if (syllableVec[syl].Accent()==accent) {
01485       for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01486         pP = &syllableVec[syl].PhonVec()[pho];
01487         if ((*pP).Type() == vowel) {
01488           PHON_FEATURES tmpPhonFeatures= (*pP).PhonFeatures();
01489           tmpPhonFeatures.jitter = true;
01490           tmpPhonFeatures.jitterRate = rate;
01491           tmpPhonFeatures.jitterMethod = method;          
01492           (*pP).setPhonFeatures(tmpPhonFeatures);
01493         }
01494       }
01495     }
01496   }
01497   if(glob.verbose)
01498     cerr << "added jitter with rate: "<<rate<<"\n";
01499 }

void phrase::addLaryngealized ( uint rate,
globalsT glob )
 

simulates laryngealization (creaky voice) at first half of vowels after unvoiced sounds.

Parameters:
uint   rate
globalsT   glob, defaultparams for klattsynth
01586                                                       {
01587   phon *pP;
01588   bool ok;
01589   if (rate > 100)
01590     error("phrase::addLaryngealized: rate>100\n",-5);
01591   for (uint syl=0; syl<syllableVec.size(); syl++) {
01592     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01593       pP = &syllableVec[syl].PhonVec()[pho];
01594       if ((*pP).Type()==vowel && ok) {
01595         PHON_FEATURES tmpPhonFeatures= (*pP).PhonFeatures();
01596         tmpPhonFeatures.creaky = true;
01597         tmpPhonFeatures.creakyStart = 0;
01598         tmpPhonFeatures.creakyStop = (*pP).FrameNum()/2;     
01599         tmpPhonFeatures.creakyRate = rate;
01600         (*pP).setPhonFeatures(tmpPhonFeatures);
01601       }
01602       if (!(*pP).Voiced())
01603         ok = true;
01604       else
01605         ok = false;
01606     }
01607   }
01608   if (glob.verbose)
01609     cerr << "added laryngealized voice at rate "<<rate<<" \n"; 
01610   calcMeanF0();
01611 }

void phrase::addTense ( uint rate,
globalsT glob )
 

simulates tense phonation at all vowels.

Parameters:
uint   rate
globalsT   glob, defaultparams for klattsynth
01535                                               {
01536   phon *pP;
01537   if (rate > 100)
01538     error("phrase::addWhisper: rate>100\n",-5);
01539   for (uint syl=0; syl<syllableVec.size(); syl++) {
01540     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01541       pP = &syllableVec[syl].PhonVec()[pho];
01542       if ((*pP).Type()==vowel) {
01543         PHON_FEATURES tmpPhonFeatures= (*pP).PhonFeatures();
01544         tmpPhonFeatures.tense = true;
01545         tmpPhonFeatures.tenseRate = rate;
01546         (*pP).setPhonFeatures(tmpPhonFeatures);
01547       }
01548     }
01549   }
01550   if (glob.verbose)
01551     cerr << "added tensed voice at rate "<<rate<<" \n"; 
01552 }

void phrase::addWave ( uint accRate,
uint nonAccRate,
uint method,
globalsT glob )
 

The intonation-contour gets changed according to the wave-model.

The whole intonationContour is changed: the phrase-accented syllables get displaced according to accRate, the syllable between phrase-accents get displaced according to nonAccRate and the other syllables get displaced by interpolation. The method decides about the interpolation,

  • method=1 : linear interpolation
  • method=4 : syllable countour is kept, i.e. whole syllable gets shifted.
Todo:
implement method=2:exponential or method=3:logarithmic interpolation
Parameters:
uint   accRate
uint   nonAccRate
uint   method
globalsT   glob, defaultparams for klattsynth
01181                                                                               {
01182   vector<uint> tmpF0Vec, indexList, targetList;
01183   phon *pP;
01184   uint frameCounter=0;
01185   
01186 
01187   if (method==LINEAR) {
01188     indexList.push_back(0);
01189     targetList.push_back(syllableVec[0].MeanF0());
01190     // read in target vals and indices
01191     for (uint syl=0; syl<syllableVec.size(); syl++) {
01192       for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01193         // cout << (*pP).Name()<<" "<<indexList.size()<<"\n";
01194         pP = &syllableVec[syl].PhonVec()[pho];
01195         if (syllableVec[syl].Accent()==sentence && (*pP).Type()==vowel) {
01196           if (indexList.size()>1) {
01197             uint actIndex = frameCounter+(*pP).FrameNum()/2;
01198             uint lastIndex = indexList[indexList.size()-1];
01199             indexList.push_back(lastIndex+((actIndex-lastIndex)/2));
01200             targetList.push_back(meanF0*nonAccRate/100);                    
01201           }
01202           indexList.push_back(frameCounter+(*pP).FrameNum()/2);
01203           targetList.push_back(syllableVec[syl].MeanF0()*accRate/100);    
01204         }
01205         for (uint i=0; i<(*pP).FrameNum(); i++)
01206           tmpF0Vec.push_back((*pP).F0Vec()[i]);
01207         frameCounter += (*pP).FrameNum();
01208       }
01209     }
01210     indexList.push_back(frameCounter);
01211     targetList.push_back(syllableVec[syllableVec.size()-1].MeanF0());
01212 
01213     // for (uint i=0; i<indexList.size(); i++)
01214     //  cout <<indexList[i]<<" "<< targetList[i] <<"\n";
01215 
01216     // modify F0Vals    
01217     for (uint i=0; i<indexList.size()-1; i++) {
01218       uint startIndex=indexList[i];
01219       uint endIndex=indexList[i+1];
01220       uint startVal=targetList[i];
01221       uint endVal=targetList[i+1];
01222 
01223       // count voiced Frames
01224       uint vocCounter = 0;
01225       for (uint k=startIndex; k<endIndex; k++)
01226         if (tmpF0Vec[k] != 0)
01227           vocCounter++;  
01228       if (startVal<endVal) {
01229         double step = (int) (endVal-startVal) / (double) vocCounter;
01230         // cout <<vocCounter<<" "<<step<<" "<<startVal<<" "<<endVal<<"\n";
01231         vocCounter = 0;
01232         for (uint k=startIndex; k<endIndex; k++) {
01233           if (tmpF0Vec[k] != 0) {
01234             tmpF0Vec[k] = startVal+(uint) (vocCounter*step);
01235             vocCounter++;
01236           }
01237         }
01238       } else if  (startVal > endVal) {
01239         double step = (int) (startVal-endVal) / (double) vocCounter;
01240         // cout <<vocCounter<<" "<<step<<" "<<startVal<<" "<<endVal<<"\n";
01241         vocCounter = 0;
01242         for (uint k=startIndex; k<endIndex; k++) {
01243           if (tmpF0Vec[k] != 0) {
01244             tmpF0Vec[k] = startVal-(uint) (vocCounter*step);
01245             vocCounter++;
01246           }
01247         }
01248       }
01249       
01250     }
01251     // assign new f0 vals to phones
01252     frameCounter = 0;
01253     for (uint syl=0; syl<syllableVec.size(); syl++) {
01254       for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01255         pP = &syllableVec[syl].PhonVec()[pho];
01256         vector<uint> tmpValVec(0);
01257         for (uint i=0; i<(*pP).FrameNum(); i++) {
01258           tmpValVec.push_back(tmpF0Vec[frameCounter]);
01259           frameCounter++;
01260         }
01261         (*pP).setF0Vec(tmpValVec, glob);
01262       }
01263     }
01264     //cout <<indexList.size()<<"\n";
01265   } else if (method==SYLLABLE_BASED) {
01266     indexList.push_back(0);
01267     targetList.push_back(100);
01268     
01269     for (uint syl=0; syl<syllableVec.size(); syl++) {
01270         if (syllableVec[syl].Accent()==sentence) {
01271           if (indexList.size()>1) {
01272             uint actIndex = syl;
01273             uint lastIndex = indexList[indexList.size()-1];
01274             indexList.push_back(lastIndex+((actIndex-lastIndex)/2));
01275             targetList.push_back(nonAccRate);       
01276           }
01277           indexList.push_back(syl);
01278           targetList.push_back(accRate);                  
01279         }      
01280     }
01281     indexList.push_back(syllableVec.size());
01282     targetList.push_back(100);
01283 
01284     for (uint i=0; i<indexList.size()-1; i++) {      
01285       uint startIndex=indexList[i];
01286       uint endIndex=indexList[i+1];
01287       uint startVal=targetList[i];
01288       uint endVal=targetList[i+1];
01289 
01290       // cout << startIndex<<" "<<startVal<<" "<<endIndex<<" "<<endVal<<"\n";
01291 
01292       if (startVal<endVal) {
01293         double step = (double) (endVal-startVal) / (double) (endIndex-startIndex);
01294         for (uint syl=startIndex; syl<endIndex; syl++) {
01295           startVal += (uint) step;
01296           // cout << startVal<<" "<<step<<"\n";
01297           syllableVec[syl].changeMeanF0(startVal);
01298         }      
01299       } else if (startVal>endVal) {
01300         double step = (double) (startVal-endVal) / (double) (endIndex-startIndex);
01301         for (uint syl=startIndex; syl<endIndex; syl++) {
01302           startVal -= (uint) step;
01303           // cout << startVal<<" "<<step<<"\n";
01304           syllableVec[syl].changeMeanF0(startVal);
01305         }      
01306       } 
01307     }
01308     
01309   } else
01310     error("phrase::addWave: method not implemented\n", -3);
01311   if (glob.verbose)
01312     cerr << "changed f0-countour to wave model at accRate "<<accRate<<" and nonAccRate "<<nonAccRate<<"\n";   
01313   calcMeanF0();
01314 }

void phrase::addWhisper ( uint rate,
globalsT glob )
 

simulates whispery phonation at all vowels.

Parameters:
uint   rate
globalsT   glob, defaultparams for klattsynth
01560                                                 {
01561   phon *pP;
01562   if (rate > 100)
01563     error("phrase::addWhisper: rate>100\n",-5);
01564   for (uint syl=0; syl<syllableVec.size(); syl++) {
01565     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01566       pP = &syllableVec[syl].PhonVec()[pho];
01567       if ((*pP).Voiced()) {
01568         PHON_FEATURES tmpPhonFeatures= (*pP).PhonFeatures();
01569         tmpPhonFeatures.whisper = true;
01570         tmpPhonFeatures.whisperRate = rate;
01571         (*pP).setPhonFeatures(tmpPhonFeatures);
01572       }
01573     }
01574   }
01575   if (glob.verbose)
01576     cerr << "added whispery voice at rate "<<rate<<" \n"; 
01577 }

void phrase::assimilateConsonants ( globalsT glob )
 

should model assimilation of voicing.

Adds voicing to unvoiced fricatives in VCV-environment. Doesn't work very well.

Todo:
find a better modelling with better smoothing.
Parameters:
globalsT   glob, defaultparams for klattsynth
01443                                                {
01444   PHON_TYPE prevT, nextT;
01445   phon *pP;
01446   for (uint syl=0; syl<syllableVec.size(); syl++) {
01447     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01448       pP = &syllableVec[syl].PhonVec()[pho];
01449       if (pho==syllableVec[syl].PhonNum()-1)
01450         nextT = syllableVec[syl+1].PhonVec()[0].Type();
01451       else
01452         nextT = syllableVec[syl].PhonVec()[pho+1].Type();
01453       
01454       if (!(syl==0&&pho==0) && !(syl==syllableVec.size()-1 && 
01455                                  pho==syllableVec[syl].PhonNum()-1))
01456         if ((*pP).Manner() == fricative_voiceless && prevT==vowel && nextT==vowel) {
01457           PHON_FEATURES tmpPhonFeatures= (*pP).PhonFeatures();
01458           tmpPhonFeatures.voiced = true;
01459           tmpPhonFeatures.vocStart = 0;
01460           tmpPhonFeatures.vocStop = (*pP).FrameNum();        
01461           (*pP).setPhonFeatures(tmpPhonFeatures);
01462         }
01463       prevT = (*pP).Type();
01464     }
01465   }
01466   if(glob.verbose)
01467     cerr << "assimilated consonants in VCV-environment\n";
01468 }

void phrase::calcDur ( ) [private]
 

00068                      {
00069   uint durSum=0;
00070   for (uint syl=0; syl<syllableVec.size(); syl++) {
00071     for (uint pho=0; pho<syllableVec[syl].PhonVec().size(); pho++) { 
00072       durSum +=  syllableVec[syl].PhonVec()[pho].Dur();
00073     }
00074   }
00075   dur = durSum;
00076 }

void phrase::calcMeanF0 ( )
 

calculates the mean val of all f0Vals.

To be done after an intonation change or falsetto or creaky voice (they change pitch also)

00031                         {
00032   uint f0Sum=0, f0Num=0;
00033   for (uint syl=0; syl<syllableVec.size(); syl++) {
00034     syllableVec[syl].calcMeanF0();
00035     for (uint pho=0; pho<syllableVec[syl].PhonVec().size(); pho++) { 
00036       if (syllableVec[syl].PhonVec()[pho].Voiced()) {
00037         for (uint f0v=0; f0v<syllableVec[syl].PhonVec()[pho].F0Vec().size(); f0v++) {
00038           f0Sum += syllableVec[syl].PhonVec()[pho].F0Vec()[f0v];
00039         }
00040         f0Num +=  syllableVec[syl].PhonVec()[pho].FrameNum();
00041       }
00042     }
00043   }
00044   
00045   meanF0 = f0Num>0 ? (uint) f0Sum/f0Num : 0;
00046 }

void phrase::changeDurManner ( PHON_MANNER manner,
uint rate,
globalsT globals )
 

change duration of specified phone-manners.

Parameters:
PHON_MANNER   manner, i.e. short_vowel, liquide, ...
uint   rate
globalsT   glob, defaultparams for klattsynth
00701                                                                          {
00702   phon *pP;
00703   if (rate < MIN_SPEECHRATE || rate > MAX_SPEECHRATE)
00704     error ("phrase::changeDurManner: rate < MIN_SPEECHRATE || rate > MAX_SPEECHRATE", -3);
00705   for (uint syl=0; syl<syllableVec.size(); syl++) {
00706     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {       
00707       if (!(syl==0&&pho==0) &&
00708           !(syl==syllableVec.size()-1&&pho==syllableVec[syl].PhonNum()-1)) {
00709         pP = &syllableVec[syl].PhonVec()[pho];
00710         if ((*pP).Manner()==manner) {
00711           uint newDur = (*pP).Dur() * rate/100;     
00712           (*pP).changeDur(newDur, glob);
00713         }
00714       }
00715     }
00716   }
00717   calcDur();
00718   if (glob.verbose)
00719     cerr << "changed duration of phones with specified manner at "<<rate<<" percent\n";
00720 }

void phrase::changeDurNonStressed ( uint rate,
uint both,
globalsT globals )
 

change duration of unstressed syllables.

By changing duration of vowel in syllable (the shortening/lengthening of syllables effects primarily the vowels). The arg <both> decides whether word-accents are counted or not.

Parameters:
uint   rate
uint   both
globalsT   glob, defaultparams for klattsynth
00650                                                                       {
00651   phon *pP;
00652   if (rate < MIN_SPEECHRATE || rate > MAX_SPEECHRATE)
00653     error ("phrase::changeDurNonStressed: rate < MIN_SPEECHRATE || rate > MAX_SPEECHRATE", -3);
00654 
00655   if (both) {
00656     for (uint syl=0; syl<syllableVec.size(); syl++) {
00657       if (syllableVec[syl].Accent()==word ||syllableVec[syl].Accent()==none) {
00658         for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {           
00659           if (!(syl==0&&pho==0) &&
00660               !(syl==syllableVec.size()-1&&pho==syllableVec[syl].PhonNum()-1)) {
00661             pP = &syllableVec[syl].PhonVec()[pho];
00662             if ((*pP).Type()==vowel) {
00663               uint newDur = (*pP).Dur() * rate/100;     
00664               (*pP).changeDur(newDur, glob);
00665             }
00666           }
00667         }
00668       }
00669     }
00670   } else { // only non-accent
00671     for (uint syl=0; syl<syllableVec.size(); syl++) {
00672       if (syllableVec[syl].Accent()==none) {
00673         for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {           
00674           if (!(syl==0&&pho==0) &&
00675               !(syl==syllableVec.size()-1&&pho==syllableVec[syl].PhonNum()-1)) {
00676             pP = &syllableVec[syl].PhonVec()[pho];
00677             if ((*pP).Type()==vowel) {
00678               uint newDur = (*pP).Dur() * rate/100;     
00679               (*pP).changeDur(newDur, glob);
00680             }
00681           }
00682         }
00683       }
00684     }      
00685   }
00686   calcDur();
00687   if (glob.verbose) {
00688     if (both)
00689       cerr << "changed duration of non phrase-stressed syllables at "<<rate<<" percent\n";
00690     else
00691       cerr << "changed duration of non stressed syllables at "<<rate<<" percent\n";      
00692   }
00693 }

void phrase::changeDurStressed ( uint rate,
uint both,
globalsT globals )
 

change duration of stressed syllables.

By changing duration of vowel in syllable (the shortening/lengthening of syllables effects primarily the vowels). The arg <both> decides whether word-accents are counted or not.

Parameters:
uint   rate
uint   both
globalsT   glob, defaultparams for klattsynth
00592                                                                    {
00593   phon *pP;
00594   if (rate < MIN_SPEECHRATE || rate > MAX_SPEECHRATE)
00595     error ("phrase::changeDurStressed: rate < MIN_SPEECHRATE || rate > MAX_SPEECHRATE", -3);
00596 
00597   if (both) {
00598     for (uint syl=0; syl<syllableVec.size(); syl++) {
00599       if (syllableVec[syl].Accent()==word ||syllableVec[syl].Accent()==sentence) {
00600         for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {           
00601           if (!(syl==0&&pho==0) &&
00602               !(syl==syllableVec.size()-1&&pho==syllableVec[syl].PhonNum()-1)) {
00603             pP = &syllableVec[syl].PhonVec()[pho];
00604             if ((*pP).Type()==vowel) {
00605               if (!(rate>100 && (*pP).Diphtong())) {
00606                 uint newDur = (*pP).Dur() * rate/100;     
00607                 (*pP).changeDur(newDur, glob);
00608               }
00609             }
00610           }
00611         }
00612       }
00613     }
00614   } else { // only sentence-accent
00615     for (uint syl=0; syl<syllableVec.size(); syl++) {
00616       if (syllableVec[syl].Accent()==sentence) {
00617         for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
00618           if (!(syl==0&&pho==0) &&
00619               !(syl==syllableVec.size()-1&&pho==syllableVec[syl].PhonNum()-1)) {
00620             
00621             pP = &syllableVec[syl].PhonVec()[pho];
00622             if ((*pP).Type()==vowel) {
00623               uint newDur = (*pP).Dur() * rate/100;     
00624               (*pP).changeDur(newDur, glob);
00625             }
00626           }
00627         }
00628       }
00629     }      
00630   }
00631   calcDur();
00632   if (glob.verbose) {
00633     if (both)
00634       cerr << "changed duration of all stressed syllables at "<<rate<<" percent\n";
00635     else
00636       cerr << "changed duration of phrase-stressed syllables at "<<rate<<" percent\n";      
00637   }
00638 }

void phrase::changeF0Range ( uint rate,
globalsT glob )
 

changes the F0-range of phrase.

The f0-contour gets expanded or compressed with the mean-f0 of the last syllable as reference. That's fine with declaration sentences.

Todo:
think about question sentences.
See also:
syllable::changeF0Range() , phon::changeF0Range()
Parameters:
uint   rate
globalsT   glob, defaultparams for klattsynth
00864                                                    {
00865   uint lastMean = syllableVec[syllableVec.size()-1].MeanF0();
00866   for (uint syl=0; syl<syllableVec.size(); syl++)
00867     syllableVec[syl].changeF0Range(rate, lastMean);
00868   
00869   if (glob.verbose)
00870     cerr << "changed F0-range at "<<rate<<" percent\n";
00871   calcMeanF0();
00872 }

void phrase::changeLastSylContour ( CONTOUR_TYPE contour,
uint gradient,
globalsT glob )
 

changes pitch-contour of last syllable to <contour>.

<contour> can be straight, rise or fall

  • straight:
  • rise/fall: last syllable gets pitch-changed according to <gradient (ST/sec)>.
See also:
phon::interpolateF0Vec()
Parameters:
uint   CONTOUR_TYPE contour
uint   gradient
globalsT   glob, defaultparams for klattsynth
00900                                                                                     {
00901   phon *pP;
00902   uint start=0, end;
00903   bool found=false;
00904   uint lastSyl=syllableVec.size()-1;
00905   switch (contour) {
00906   case straight:
00907     start=syllableVec[lastSyl].MeanF0();
00908     for (uint pho=0; pho<syllableVec[lastSyl].PhonNum(); pho++) {
00909       pP = &syllableVec[lastSyl].PhonVec()[pho];
00910       if ((*pP).Voiced()) {
00911         (*pP).interpolateF0Vec(start, start);
00912       }
00913     }  
00914     break;
00915   case rise:
00916     found=false;
00917     for (uint pho=0; pho<syllableVec[lastSyl].PhonNum(); pho++) {
00918       pP = &syllableVec[lastSyl].PhonVec()[pho];
00919       for (uint i=0; i<(*pP).F0Vec().size(); i++) {
00920         if ((*pP).F0Vec()[i] != 0) {
00921           start = (*pP).F0Vec()[i];
00922           found=true;
00923           break;
00924         }
00925       }
00926       if (found)
00927         break;
00928     }
00929     for (uint pho=0; pho<syllableVec[lastSyl].PhonNum(); pho++) {
00930       pP = &syllableVec[lastSyl].PhonVec()[pho];
00931       if ((*pP).Voiced()) {
00932         end = (uint) gradient2Hz(start, (*pP).Dur(), gradient);
00933         // cout <<"start: "<< start << " " << end << "\n";
00934         (*pP).interpolateF0Vec(start, end);
00935         start = end;
00936       }
00937     }
00938     break;
00939   case fall:
00940     for (uint pho=0; pho<syllableVec[lastSyl].PhonNum(); pho++) {
00941       pP = &syllableVec[lastSyl].PhonVec()[pho];
00942       if ((*pP).MeanF0()!=0) {
00943         start=(*pP).MeanF0();
00944         break;
00945       }
00946     }
00947     for (uint pho=0; pho<syllableVec[lastSyl].PhonNum(); pho++) {
00948       pP = &syllableVec[lastSyl].PhonVec()[pho];
00949       if ((*pP).Voiced()) {
00950         end = start - ((uint) gradient2Hz(start, (*pP).Dur(), gradient) - start);
00951         // cout <<"start: "<< start << " " << end << "\n";
00952         (*pP).interpolateF0Vec(start, end);
00953         start = end;
00954       }
00955     }
00956     break;
00957   }
00958   syllableVec[lastSyl].calcMeanF0();
00959   calcMeanF0();
00960   if (glob.verbose)
00961     cerr << "changed f0-countour of last syllable to gradient "<<gradient<<" \n"; 
00962 }

void phrase::changeMeanF0 ( uint rate,
globalsT glob )
 

all nonzero f0Vals get multiplied by <rate> in percent.

(so rate=100 means no change).

See also:
syllable::changeMeanF0() , phon::changeMeanF0()
Parameters:
uint   rate
globalsT   glob, defaultparams for klattsynth
00766                                                   {
00767   for (uint syl=0; syl<syllableVec.size(); syl++) {
00768     syllableVec[syl].changeMeanF0(rate);
00769   }
00770   calcMeanF0();
00771   if (glob.verbose)
00772     cerr << "changed avr. F0 at "<<rate<<" percent\n";
00773 }

void phrase::changePhraseContour ( CONTOUR_TYPE contour,
uint rate,
globalsT glob )
 

changes pitch-contour of whole phrase to <contour>.

<contour> can be straight, rise or fall

  • straight: all syllable-meanF0Vals become meanF0Val
  • rise/fall: last syllable gets pitch-changed according to <rate>, all syllables before get changed in percentage to distance from last syllable
    Parameters:
    uint   CONTOUR_TYPE contour
    uint   rate
    globalsT   glob, defaultparams for klattsynth
    01113                                                                                {
    01114   uint tmpRate;
    01115   int step = ((int)rate - 100)/(int)syllableVec.size();
    01116   tmpRate=0;
    01117 
    01118   if (contour==rise || contour==fall) {
    01119     for (uint tmpSyl=0; tmpSyl <syllableVec.size(); tmpSyl++) { 
    01120       tmpRate = 100 + (step * tmpSyl);
    01121       // cout << tmpSyl << " " << step<<" "<<tmpRate << " " << rate<<"\n";
    01122       for (uint pho=0; pho<syllableVec[tmpSyl].PhonNum(); pho++) 
    01123         syllableVec[tmpSyl].PhonVec()[pho].changeMeanF0(tmpRate);    
    01124     }
    01125   } else if (contour == straight) {
    01126     // error("feature not implemented\n", -3);
    01127     for (uint tmpSyl=0; tmpSyl <syllableVec.size(); tmpSyl++) { 
    01128       int f0MeanDiff = (int) ((double) meanF0 / (double) syllableVec[tmpSyl].MeanF0() * 100.0);
    01129       
    01130       // cout <<f0MeanDiff <<"\n";
    01131       for (uint pho=0; pho<syllableVec[tmpSyl].PhonNum(); pho++) {
    01132         syllableVec[tmpSyl].PhonVec()[pho].changeMeanF0(f0MeanDiff);
    01133         ;
    01134       }    
    01135     }
    01136 
    01137   }
    01138   if (glob.verbose)
    01139     cerr << "changed f0-countour of phrase at rate "<<rate<<" \n"; 
    01140   calcMeanF0();
    01141 }
    

void phrase::changePhraseContourToAccent ( uint rate,
globalsT glob )
 

changes pitch-contour of regions of phrase divided by phraseaccents to <contour>.

Like changePhraseContour(), but repeated for every accented syllable. A straight contour is not implemented, if rate>100 it's a rise and if rate<100 it's a fall.

Parameters:
uint   rate
globalsT   glob, defaultparams for klattsynth
01150                                                                  {
01151   uint sylC=0, tmpRate;
01152   for (uint syl=0; syl<syllableVec.size(); syl++) {
01153     if (syllableVec[syl].Accent()==sentence) { // if the syl has accent
01154       int step = ((int)rate - 100)/(int)sylC;
01155       tmpRate=0;
01156       for (uint tmpSyl=syl-sylC; tmpSyl <= syl; tmpSyl++) { // foreach syl before the accent    
01157         tmpRate = 100 + (step *  (tmpSyl-(syl-sylC)));
01158         //      cout << tmpSyl << " " << step<<" "<<tmpRate << " " << rate<<"\n";
01159         syllableVec[tmpSyl].changeMeanF0(tmpRate);
01160         
01161       }
01162       sylC=0;
01163     } else
01164       sylC++;
01165   }
01166   if (glob.verbose)
01167     cerr << "changed f0-countour to accented syllables at rate "<<rate<<" \n"; 
01168   calcMeanF0();
01169 }

void phrase::changePitchContourStressed ( CONTOUR_TYPE contour,
uint gradient,
uint both,
globalsT glob )
 

changes pitch-contour of stressed syllables to <contour>.

<contour> can be straight, rise or fall

  • straight: all nonzero f0Vals of acc. syllable become meanF0Val
  • rise: all nonzero f0Vals rise from firstVal to gradient (in ST/sec)
  • fall: all nonzero f0Vals fall from meanVal of first voiced phone to gradient
The arg <both> decides whether word-accents are counted or not.
See also:
CONTOUR_TYPE , phon::interpolateF0Vec()
Parameters:
uint   CONTOUR_TYPE contour
uint   gradient
globalsT   glob, defaultparams for klattsynth
00968                                                                                                      {
00969   phon *pP;
00970   uint start=0, end;
00971   bool found=false;
00972   if (both) {
00973     for (uint syl=0; syl<syllableVec.size()-1; syl++) {      
00974       found=false;
00975       start=0;
00976       if (syllableVec[syl].Accent()==word || syllableVec[syl].Accent()==sentence) {
00977         // cout << syllableVec[syl].MeanF0() << "\n";
00978 
00979         switch (contour) {
00980         case straight:
00981           syllableVec[syl].changeF0Range(gradient);
00982           break;
00983         case rise:
00984           found=false;
00985           for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
00986             pP = &syllableVec[syl].PhonVec()[pho];
00987             for (uint i=0; i<(*pP).F0Vec().size(); i++) {
00988               if ((*pP).F0Vec()[i] != 0) {
00989                 start = (*pP).F0Vec()[i];
00990                 found=true;
00991                 break;
00992               }
00993             }
00994             if (found)
00995               break;
00996           }
00997           for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
00998             pP = &syllableVec[syl].PhonVec()[pho];
00999             if ((*pP).Voiced()) {
01000               end = (uint) gradient2Hz(start, (*pP).Dur(), gradient);
01001               // cout <<"start: "<< start << " " << end << "\n";
01002               (*pP).interpolateF0Vec(start, end);
01003               start = end;
01004             }
01005           }
01006           break;
01007         case fall:
01008           start = syllableVec[syl].MeanF0();
01009           // start fall from mean f0Val
01010           /*
01011           for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01012             pP = &syllableVec[syl].PhonVec()[pho];
01013             if ((*pP).MeanF0()!=0) {
01014               start=(*pP).MeanF0();
01015               break;
01016             }
01017           }
01018           */
01019           // start fall from first nonzero f0Val
01020           //      for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01021           //  pP = &syllableVec[syl].PhonVec()[pho];
01022           // for (uint i=0; i<(*pP).FrameNum(); i++) {
01023           //  if ((*pP).F0Vec()[i]!=0) {
01024           //start=(*pP).F0Vec()[i];
01025           //break;
01026           //  }
01027           //}
01028           //}
01029           for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01030             pP = &syllableVec[syl].PhonVec()[pho];
01031             if ((*pP).Voiced()) {
01032               end = start - ((uint) gradient2Hz(start, (*pP).Dur(), gradient) - start);
01033               // cout <<"start: "<< start << " " << end << "\n";
01034               (*pP).interpolateF0Vec(start, end);
01035               start = end;
01036             }
01037           }
01038           break;
01039         }
01040       }
01041     } 
01042   } else { // only sentence-accent
01043     for (uint syl=0; syl<syllableVec.size()-1; syl++) {
01044       if (syllableVec[syl].Accent()==sentence) {
01045         switch (contour) {
01046         case straight:
01047           syllableVec[syl].changeF0Range(gradient);
01048           break;
01049         case rise:
01050           found=false;
01051           for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01052             pP = &syllableVec[syl].PhonVec()[pho];
01053             for (uint i=0; i<(*pP).F0Vec().size(); i++) {
01054               if ((*pP).F0Vec()[i] != 0) {
01055                 start = (*pP).F0Vec()[i];
01056                 found=true;
01057                 break;
01058               }
01059             }
01060             if (found)
01061               break;
01062           }
01063           for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01064             pP = &syllableVec[syl].PhonVec()[pho];
01065             if ((*pP).Voiced()) {
01066               end = (uint) gradient2Hz(start, (*pP).Dur(), gradient);
01067               (*pP).interpolateF0Vec(start, end);
01068               start = end;
01069             }
01070           }
01071           break;
01072         case fall:
01073           // find first nonzero f0Val
01074           for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01075             pP = &syllableVec[syl].PhonVec()[pho];
01076             for (uint i=0; i<(*pP).FrameNum(); i++) {
01077               if ((*pP).F0Vec()[i]!=0) {
01078                 start=(*pP).F0Vec()[i];
01079                 break;
01080               }
01081             }
01082           }
01083           for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01084             pP = &syllableVec[syl].PhonVec()[pho];
01085             if ((*pP).Voiced()) {
01086               end = start - ((uint) gradient2Hz(start, (*pP).Dur(), gradient) - start);
01087               (*pP).interpolateF0Vec(start, end);
01088               start = end;
01089             }
01090           }
01091           break;
01092         }
01093       }
01094     }
01095   } 
01096   if (glob.verbose)
01097     cerr << "changed f0-countour of stressed syllables to gradient "<<gradient<<" \n"; 
01098   calcMeanF0();
01099 }

void phrase::changePreStressedAvrF0 ( uint rate,
uint both,
globalsT glob )
 

change avr pitch of the syllables before stressed syllables.

All nonzero f0Vals get multiplied by <rate> in percent. The arg <both> decides whether word-accents are counted or not. The last syllable is not affected (even if stressed), but has to be provided specially.

Parameters:
uint   rate
uint   both
globalsT   glob, defaultparams for klattsynth
00836                                                                        {
00837   if (both) {
00838     for (uint syl=0; syl<syllableVec.size()-1; syl++) {
00839       if (syllableVec[syl+1].Accent()==word ||syllableVec[syl+1].Accent()==sentence) {
00840         syllableVec[syl].changeMeanF0(rate);
00841       }
00842     }
00843   } else { // only sentence-accent
00844     for (uint syl=0; syl<syllableVec.size(); syl++) {
00845       if (syllableVec[syl+1].Accent()==sentence) {
00846         syllableVec[syl].changeMeanF0(rate);
00847       }
00848     }      
00849   }
00850   if (both)
00851     cerr << "changed avr. F0 of all syls prior to stress at "<<rate<<" percent\n";
00852   else
00853     cerr << "changed avr. F0 of syls prior to phrase-stress at "<<rate<<" percent\n";      
00854   calcMeanF0();
00855 }

void phrase::changeSpeechRate ( uint rate,
globalsT globals,
int method )
 

changes duration of all phones.

if method = 0, then change duration of all phones in the utterance by factor <rate> if method = 1, then phrasestressed vowels get 100% change, wordstressed vowels get 90 % change, all others get 80 % change (phonetically adequate)

Parameters:
uint   rate
globalsT   glob, defaultparams for klattsynth
uint   method
00526                                                                    {
00527   int absChange, wordChange, vowelChange, consChange;
00528   phon *pP;  
00529   uint newDur;
00530   if (method == 0) {
00531     for (uint syl=0; syl<syllableVec.size(); syl++) {
00532       for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
00533         if (!(syl==0&&pho==0) &&
00534             !(syl==syllableVec.size()-1&&pho==syllableVec[syl].PhonNum()-1)) {
00535           
00536           pP = &syllableVec[syl].PhonVec()[pho];
00537           if (!(rate>100 && syllableVec[syl].PhonVec()[pho].Diphtong())) {
00538             newDur = (*pP).Dur() * rate/100;     
00539             (*pP).changeDur(newDur, glob);
00540           }
00541         }
00542       }
00543     }
00544   } else if (method == 1) {
00545     absChange = abs(100-(int)rate);
00546     if (rate>100) {
00547       wordChange = 100 + (int) (absChange*0.9);
00548       vowelChange = 100 + (int) (absChange*0.7);
00549       consChange = 100 + (int) (absChange*0.5);
00550     } else {
00551       wordChange = 100 - (int) (absChange*0.9);
00552       vowelChange = 100 - (int) (absChange*0.7);
00553       consChange = 100 - (int) (absChange*0.5);
00554     }
00555     //    cout << wordChange<<" "<<vowelChange<<" "<<consChange<<"\n";
00556     for (uint syl=0; syl<syllableVec.size(); syl++) {
00557       for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
00558         if (!(syl==0&&pho==0) &&
00559             !(syl==syllableVec.size()-1&&pho==syllableVec[syl].PhonNum()-1)) {
00560           
00561           pP = &syllableVec[syl].PhonVec()[pho];
00562           if (syllableVec[syl].Accent()==sentence && (*pP).Type()==vowel)
00563             newDur = syllableVec[syl].PhonVec()[pho].Dur() * rate/100;
00564           else if  (syllableVec[syl].Accent()==word && (*pP).Type()==vowel)
00565             newDur = syllableVec[syl].PhonVec()[pho].Dur() * wordChange/100;
00566           else if  ((*pP).Type()==vowel)
00567             newDur = syllableVec[syl].PhonVec()[pho].Dur() * vowelChange/100;
00568           else
00569             newDur = syllableVec[syl].PhonVec()[pho].Dur() * consChange/100;
00570           
00571           syllableVec[syl].PhonVec()[pho].changeDur(newDur, glob);
00572         }
00573       }
00574     }
00575   } else {
00576     error("phrase::changeSpeechRate: undefined method", -3);
00577   }
00578   calcDur();
00579   if (glob.verbose)
00580     cerr << "changed speechrate at "<<rate<<" percent\n";
00581 }

void phrase::changeStressedAvrF0 ( uint rate,
uint both,
globalsT glob )
 

change mean pitch of stressed syllables.

All nonzero f0Vals get multiplied by <rate> in percent. The arg <both> decides whether word-accents are counted or not. The last syllable is not affected (even if stressed), but has to be provided specially.

Parameters:
uint   rate
uint   both
globalsT   glob, defaultparams for klattsynth
00802                                                                     {
00803   if (both) {
00804     for (uint syl=0; syl<syllableVec.size()-1; syl++) {
00805       if (syllableVec[syl].Accent()==word || syllableVec[syl].Accent()==sentence) {
00806         // cout << syllableVec[syl].MeanF0() << " ";
00807         syllableVec[syl].changeMeanF0(rate);
00808         // cout << syllableVec[syl].MeanF0() << "\n";
00809         
00810       }
00811     }
00812   } else { // only sentence-accent
00813     for (uint syl=0; syl<syllableVec.size(); syl++) {
00814       if (syllableVec[syl].Accent()==sentence) {
00815         syllableVec[syl].changeMeanF0(rate);
00816       }
00817     }      
00818   }
00819   if (both)
00820     cerr << "changed avr. F0 of all stressed syllables at "<<rate<<" percent\n";
00821   else
00822     cerr << "changed avr. F0 of phrase-stressed syllables at "<<rate<<" percent\n";      
00823   calcMeanF0();
00824 }

void phrase::changeStressedInt ( int dBVal,
uint both,
globalsT globals )
 

change intensity of stressed syllables.

The arg <both> decides whether word-accents are counted or not. The dBval is added to intensity of the vowels in the syllables, so it can be negative to lower the intensity. If the result'd become negative, it's set to zero.

Parameters:
int   dBval
uint   both
globalsT   glob, defaultparams for klattsynth
00732                                                                   {
00733   if (both) {
00734     for (uint syl=0; syl<syllableVec.size()-1; syl++) {
00735       if (syllableVec[syl].Accent()==sentence) {
00736         syllableVec[syl].changeAvrInt(dBVal);
00737       }
00738       if (syllableVec[syl].Accent()==word) {
00739         syllableVec[syl].changeAvrInt(dBVal/2);
00740       }
00741       
00742     }
00743   } else { // only sentence-accent
00744     for (uint syl=0; syl<syllableVec.size(); syl++) {
00745       if (syllableVec[syl].Accent()==sentence) {
00746         syllableVec[syl].changeAvrInt(dBVal);
00747       }
00748     }      
00749   }
00750   if (both)
00751     cerr << "changed avr. intensuty of all stressed syllables at "<<dBVal<<" dB\n";
00752   else
00753     cerr << "changed avr. intensity of phrase-stressed syllables at "<<dBVal<<" dB\n";      
00754 }

void phrase::changeVariability ( uint rate,
globalsT glob )
 

changes the F0-variability.

The f0-contour of each syllable gets expanded or compressed with the mean-f0 of the syllable as reference.

Parameters:
uint   rate
globalsT   glob, defaultparams for klattsynth
00881                                                        {
00882   for (uint syl=0; syl<syllableVec.size(); syl++) {
00883     syllableVec[syl].changeF0Range(rate, syllableVec[syl].MeanF0());
00884   }
00885   if (glob.verbose)
00886     cerr << "changed F0-variability at "<<rate<<" percent\n";  
00887   calcMeanF0();
00888 }

void phrase::coarticulation ( uint rate,
CO_TYPE coType,
globalsT glob )
 

model coarticulation effects.

Each phone gets features added at the borders from the neighboring phones, depending on coType:

  • regressiv,
  • progrssive,
  • both.
results in very disturbed output up to now.
Todo:
find a better modelling with better smoothing.
Parameters:
uint   rate
CO_TYPE   coType
globalsT   glob, defaultparams for klattsynth
01421                                                                     {
01422   phon *pP;
01423   for (uint syl=0; syl<syllableVec.size(); syl++) {
01424     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01425       pP = &syllableVec[syl].PhonVec()[pho];
01426       PHON_FEATURES tmpPhonFeatures= (*pP).PhonFeatures();
01427       tmpPhonFeatures.coarticulation = true;
01428       tmpPhonFeatures.coarticulationRate = rate;
01429       tmpPhonFeatures.coarticulationType = coType;      
01430       (*pP).setPhonFeatures(tmpPhonFeatures);
01431     }
01432   }     
01433   if(glob.verbose)
01434     cerr << "added coarticulation with rate: "<<rate<<"\n";
01435 }

void phrase::headSize ( uint rate,
globalsT glob )
 

experiment: shift formant-values to model different head-sizes.

not really implemented yet.

Parameters:
uint   rate
globalsT   glob, defaultparams for klattsynth
01396                                               {
01397   phon *pP;
01398   for (uint syl=0; syl<syllableVec.size(); syl++) {
01399     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01400       pP = &syllableVec[syl].PhonVec()[pho];
01401       if ((*pP).Voiced()) {
01402         PHON_FEATURES tmpPhonFeatures= (*pP).PhonFeatures();
01403         tmpPhonFeatures.headSize = true;
01404         tmpPhonFeatures.headSizeRate = rate;      
01405         (*pP).setPhonFeatures(tmpPhonFeatures);
01406       }
01407     }
01408   }     
01409   if (glob.verbose)
01410     cerr <<"changed head-size at rate: "<<rate<<"\n";
01411 }

void phrase::makeTest ( globalsT globals,
uint dur )
 

fill a phrase with one syllable with one phone of duration dur (in msec) with parameters taken from globals.

Useful for finding the right parameters for certain phones.

Parameters:
globalsT   glob, defaultparams for klattsynth
uint   duration of output in msec.
00113                                                 {
00114   syllable tmpSyl;
00115   phon tmpPhon("_", dur, globals);
00116   tmpSyl.addPhon(tmpPhon);
00117   syllableVec.push_back(tmpSyl);
00118   calcDur();
00119 }

void phrase::modelFeatures ( globalsT & kg )
 

model voice-source and articulation-tract filter parameters for each phone according to it's assigned features.

sets bool xxxDyn true: i.e. all changung parmaters are marked to be dynamic.

Parameters:
globalsT   glob, defaultparams for klattsynth
00145                                             {
00146   phon *pP, *nextpP, *prevpP=NULL;
00147 
00148   for (uint syl=0; syl<syllableVec.size(); syl++) {
00149     uint sylMeanF0 = syllableVec[syl].MeanF0();
00150     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
00151       if (pho==syllableVec[syl].PhonNum()-1)
00152         if (syl==syllableVec.size()-1) 
00153           nextpP = NULL;
00154         else
00155           nextpP = &(syllableVec[syl+1].PhonVec()[0]);
00156       else
00157         nextpP = &(syllableVec[syl].PhonVec()[pho+1]);
00158 
00159       pP =  &(syllableVec[syl].PhonVec()[pho]);
00160       (*pP).modelFeatures(sylMeanF0, globals, prevpP, nextpP);
00161       prevpP = pP;
00162     }
00163   }
00164 }

void phrase::modelKlattParameters ( globalsT & globals )
 

model voice-source and articulation-tract filter parameters for each phone for normal voice.

They can later be overwritten by modelFeatures. sideeffect: sets bool xxxDyn true: i.e. all changung parmaters are marked to be dynamic.

See also:
modelFeatures()
Parameters:
globalsT   glob, defaultparams for klattsynth
00134                                                    {
00135   phon *tmpPhonP;
00136   for (uint syl=0; syl<syllableVec.size(); syl++) {
00137     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
00138       tmpPhonP =  &(syllableVec[syl].PhonVec()[pho]);
00139       (*tmpPhonP).setSoundSource(globals);
00140       (*tmpPhonP).setArticulationTractFilter(globals);
00141     }
00142   }
00143 }

void phrase::overshootVowels ( ACCENT_TYPE accent,
uint rate,
globalsT glob )
 

enhance the vowel precision.

All formantVals in f1 and f2 of vowels in syllables with accent get displaced away from the center freqencies by adding the percentage by rate and distance to center frequency.

Parameters:
ACCENT_TYPE   accent
uint   rate
globalsT   glob, defaultparams for klattsynth
01327                                                                          {
01328   phon *pP;
01329   for (uint syl=0; syl<syllableVec.size(); syl++) {
01330     if (syllableVec[syl].Accent()==accent) {
01331       for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01332         pP = &syllableVec[syl].PhonVec()[pho];
01333         if ((*pP).Type()==vowel) { // && ! (*pP).Diphtong()) {
01334           PHON_FEATURES tmpPhonFeatures= (*pP).PhonFeatures();
01335           tmpPhonFeatures.overshoot = true;
01336           tmpPhonFeatures.overshootRate = rate;
01337           (*pP).setPhonFeatures(tmpPhonFeatures);
01338         }
01339       }
01340     }
01341   }
01342   if (glob.verbose)
01343     cerr << "added overshoot at "<<rate<<" for accent-type: "<<(uint)accent<<"\n";
01344 }

void phrase::printKlattFile ( ostream & outFile )
 

prints klatt-file (iles&simmons-format).

If used, the bool sensyn in the global paramters should be false.

See also:
printSenSynFile()
Parameters:
ostream   &outFile
00121                                             {
00122   outFile <<  "# parameter file for the klatt-formant speech-synthesizer, implementation of iles & simmons, (version with comments possible!) \n";
00123   outFile <<  "# generated by emoSyn - speechsynthesizer-frontend for emotional speech, author felixbur@kgw.tu-berlin.de\n";
00124   for (uint syl=0; syl<syllableVec.size(); syl++) {
00125     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
00126       outFile <<  "# name of phone: " << syllableVec[syl].PhonVec()[pho].Name() << "\n";
00127       outFile <<  "# meaning of parameters: \n";
00128       outFile <<  "# f0 av f1 b1 f2 b2 f3 b3 f4 b4 f5 b5 f6 b6 fnz bnz fnp bnp asp kopen aturb tilt af skew a1 b1p a2 b2p a3 b3p a4 b4p a5 b5p a6 b6p anp ab avp gain\n# values:\n";
00129       syllableVec[syl].PhonVec()[pho].printKlattFrames(outFile);
00130     }
00131   }
00132 }

void phrase::printLabelFile ( ostream & outFile,
globalsT globals )
 

prints label-file (esps-format).

Parameters:
ostream   &outFile
globalsT   glob, defaultparams for klattsynth
00200                                                               {
00201   double time=0;  
00202   phon *pP;
00203 
00204   outFile << "signal emoSyn-output\n";
00205   outFile << "type 0\n";
00206   outFile << "comment created by emoSyn\n";
00207   outFile << "font -misc-*-bold-*-*-*-15-*-*-*-*-*-*-*\n";
00208   outFile << "separator ;\n";
00209   outFile << "nfields 1\n";
00210   outFile << "#\n";
00211   for (uint syl=0; syl<syllableVec.size(); syl++) {
00212     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
00213       pP = &syllableVec[syl].PhonVec()[pho];
00214       outFile << "\t" << time << "\t-1 ";
00215       outFile << (*pP).Name();
00216       outFile << "\n"; 
00217       // print features: overshoot, undershoot
00218       if ((*pP).PhonFeatures().overshoot) {
00219         outFile << "\t" << time << "\t-1 " << "+overshoot\n";  
00220       } 
00221       if ((*pP).PhonFeatures().undershoot) {
00222         outFile << "\t" << time << "\t-1 " << "+undershoot\n";  
00223       } 
00224       // print features: breathy
00225       if ((*pP).PhonFeatures().breathy) {
00226         double bS = (*pP).PhonFeatures().brtStart*(double) globals.ui / 1000;
00227         outFile << "\t" << time + bS << "\t-1 " << "+brt\n";
00228         if ((*pP).PhonFeatures().brtStop < (*pP).Dur()) {
00229           double bE = (*pP).PhonFeatures().brtStop*(double) globals.ui / 1000;
00230           outFile << "\t" << time + bE << "\t-1 " << "-brt\n";  
00231         }
00232       }
00233       // print features: voiced      
00234       if ((*pP).PhonFeatures().voiced) {
00235         if (!(*pP).Voiced()) {
00236           double vS = (*pP).PhonFeatures().vocStart*(double) globals.ui / 1000;      
00237           outFile << "\t" << time + vS << "\t-1 " << "+voc\n";
00238           if ((*pP).PhonFeatures().vocStop < (*pP).Dur()) {
00239             double vE = (*pP).PhonFeatures().vocStop*(double) globals.ui / 1000;
00240             outFile << "\t" << time + vE << "\t-1 " << "-voc\n";  
00241           }
00242         } else {
00243           double vE = (*pP).PhonFeatures().vocStop*(double) globals.ui / 1000;       
00244           outFile << "\t" << time + vE << "\t-1 " << "-voc\n";
00245           if ((*pP).PhonFeatures().vocStart < (*pP).Dur()) {
00246             double vS = (*pP).PhonFeatures().vocStart*(double) globals.ui / 1000;    
00247             outFile << "\t" << time + vS << "\t-1 " << "+voc\n";  
00248           }
00249         }
00250       }
00251       // print features: laryngealized
00252       if ((*pP).PhonFeatures().creaky) {
00253         double bS = (*pP).PhonFeatures().creakyStart*(double) globals.ui / 1000;
00254         outFile << "\t" << time + bS << "\t-1 " << "+lar\n";
00255         if ((*pP).PhonFeatures().creakyStop < (*pP).Dur()) {
00256           double bE = (*pP).PhonFeatures().creakyStop*(double) globals.ui / 1000;
00257           outFile << "\t" << time + bE << "\t-1 " << "-lar\n";  
00258         }
00259       }
00260       time += (double) (*pP).Dur()/1000;
00261     }
00262   }
00263   outFile << "\n"; 
00264 }

void phrase::printPhoFile ( ostream & outFile,
globalsT glob )
 

prints pho-file (mbrola-format).

It's used for resynthesis. If the global parameter copyDB is true, the syllable borders get printed as well.

Parameters:
ostream   &outFile
globalsT   glob, defaultparams for klattsynth
00166                                                          {
00167   vector<uint> tmpF0ValVec(0);
00168   vector<uint> tmpF0TimeVec(0);
00169   phon *pP;
00170   uint time;
00171   for (uint syl=0; syl<syllableVec.size(); syl++) {
00172     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
00173       pP = &syllableVec[syl].PhonVec()[pho];
00174       if (glob.copyDB) {
00175         outFile << (*pP).Name() << " ";
00176         outFile << (*pP).Dur() << " ";
00177         if ((*pP).Voiced()) {
00178           for (uint f0Val=0; f0Val<(*pP).F0Vec().size();f0Val++) {
00179             time = f0Val*(100/(*pP).F0Vec().size());
00180             outFile << time << " " << (*pP).F0Vec()[f0Val]/10 << " ";
00181           }
00182         }
00183       } else { 
00184         tmpF0ValVec =  (*pP).F0ValVec();
00185         tmpF0TimeVec = (*pP).F0TimeVec();
00186         outFile << (*pP).Name() << " ";
00187         outFile << (*pP).Dur() << " ";
00188         for (uint f0Val=0; f0Val<(*pP).FrameNum();f0Val++)
00189           outFile << tmpF0TimeVec[f0Val] << " "
00190                   << tmpF0ValVec[f0Val]*10 << " ";
00191       }
00192       outFile << "\n"; 
00193     }
00194     if (glob.copyDB)
00195       outFile << "- " << (int) syllableVec[syl].Accent() << "\n"; 
00196   }
00197   outFile << "\n"; 
00198 }

void phrase::printPhonFeatures ( ostream & outFile )
 

prints phonfeatures to outFile (debugging).

Parameters:
ostream   &outFile
00089                                                {
00090   phon *pP;
00091   for (uint syl=0; syl<syllableVec.size(); syl++) {
00092     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
00093       pP = &syllableVec[syl].PhonVec()[pho];
00094       outFile <<  (*pP).Name() << " " << (*pP).Diphtong() << "\n"; 
00095         //tmpPhonFeatures.voiced << "\n";     
00096     } 
00097   }
00098 }

void phrase::printPhonMeanF0 ( ostream & outFile )
 

prints means of f0-contour per phon to outFile (debugging).

Parameters:
ostream   &outFile
00101                                              {
00102   vector<phon> tmpPhonVec;  
00103   for (uint syl=0; syl<syllableVec.size(); syl++) {
00104     tmpPhonVec = syllableVec[syl].PhonVec();
00105     for (uint pho=0; pho<tmpPhonVec.size(); pho++) {      
00106       outFile << tmpPhonVec[pho].MeanF0() << " ";
00107     }
00108     outFile << "\t"; 
00109   }
00110   outFile << "\n"; 
00111 }

void phrase::printSenSynFile ( globalsT globals,
ostream & outFile )
 

prints klatt-file (sensymetrics-format).

If used, the bool sensyn in the global paramters should be true.

See also:
printKlattFile()
Parameters:
globalsT   glob, defaultparams for klattsynth
ostream   &outFile
01667                                                             {
01668   uint start=0;
01669   outFile <<  "parameter file for the klatt-formant speech-synthesizer\n implementation: sensyn, sensimetrics coorp. \n";
01670   outFile <<  "generated by emoSyn\n - speechsynthesizer-frontend for emotional speech,\n author felixbur@globw.tu-berlin.de\n";
01671   outFile <<  "6\n7\n8\n9\n";
01672   outFile <<  "60 parameters\n";
01673   outFile <<  "11\n12\n13\n";
01674 
01675   outFile <<  "DU   C   30   "<<dur<<"  5000 Duration of the utterance, in msec\n";
01676   outFile <<  "UI   C    1     "<<glob.ui<<"    20  Update interval for parameter reset, in msec\n";
01677   outFile <<  "SR   C 5000 "<<glob.sr<<" 20000  Output sampling rate, in samples/sec\n";
01678   outFile <<  "NF   C    1     "<<glob.nf<<"     6  Number of formants in cascade branch\n";
01679   outFile <<  "SS   C    1     "<<glob.ss<<"     3  Source switch (1=impulse, 2=natural, 3=LF model)\n";
01680   outFile <<  "RS   C    1     "<<glob.rs<<"  8191  Random seed (initial value of random # generator)\n";
01681   outFile <<  "SB   C    0     "<<glob.sb<<"     1  Same noise burst, reset RS if AF=AH=0, 0=no,1=yes\n";
01682   outFile <<  "CP   C    0     "<<glob.cp<<"     1  0=Cascade, 1=Parallel tract excitation by AV\n";
01683   outFile <<  "OS   C    0     "<<glob.os<<"    20  Output selector (0=normal,1=voicing source,...)\n";
01684   outFile <<  "GV   C    0    "<<glob.gv<<"    80  Overall gain scale factor for AV, in dB\n";
01685   outFile <<  "GH   C    0    "<<glob.gh<<"    80  Overall gain scale factor for AH, in dB\n";
01686   outFile <<  "GF   C    0    "<<glob.gf<<"    80  Overall gain scale factor for AF, in dB\n";
01687   if (glob.f0Dyn) 
01688     outFile <<  "F0   V    0  "<<glob.f0<<"  5000  Fundamental frequency, in tenths of a Hz\n";
01689   else
01690     outFile <<  "F0   v    0  "<<glob.f0<<"  5000  Fundamental frequency, in tenths of a Hz\n";
01691   if (glob.avDyn)
01692     outFile <<  "AV   V    0    "<<glob.av<<"    80  Amplitude of voicing, in dB\n";
01693   else
01694     outFile <<  "AV   v    0    "<<glob.av<<"    80  Amplitude of voicing, in dB\n"; 
01695   if (glob.oqDyn)
01696     outFile <<  "OQ   V   10    "<<glob.oq<<"    99  Open quotient (voicing open-time/period), in %\n";
01697   else
01698     outFile <<  "OQ   v   10    "<<glob.oq<<"    99  Open quotient (voicing open-time/period), in %\n";
01699   if (glob.sqDyn)
01700     outFile <<  "SQ   V  100   "<<glob.sq<<"   500  Speed quotient (rise/fall time, LF model), in %\n";
01701   else
01702     outFile <<  "SQ   v  100   "<<glob.sq<<"   500  Speed quotient (rise/fall time, LF model), in %\n";
01703   if (glob.tlDyn)
01704     outFile <<  "TL   V    0     "<<glob.tl<<"    41  Extra tilt of voicing spectrum, dB down @ 3 kHz\n";
01705   else
01706     outFile <<  "TL   v    0     "<<glob.tl<<"    41  Extra tilt of voicing spectrum, dB down @ 3 kHz\n";
01707   if (glob.flDyn)
01708     outFile <<  "FL   V    0     "<<glob.fl<<"   100  Flutter (random fluct in f0), in % of maximum\n";
01709   else
01710     outFile <<  "FL   v    0     "<<glob.fl<<"   100  Flutter (random fluct in f0), in % of maximum\n";  
01711   if (glob.diDyn) 
01712     outFile <<  "DI   V    0     "<<glob.di<<"   100  Diplophonia (alt periods closer), in % of max\n";
01713   else
01714     outFile <<  "DI   v    0     "<<glob.di<<"   100  Diplophonia (alt periods closer), in % of max\n";
01715   if (glob.ahDyn)
01716     outFile <<  "AH   V    0     "<<glob.ah<<"    80  Amplitude of aspiration, in dB\n";
01717   else
01718     outFile <<  "AH   v    0     "<<glob.ah<<"    80  Amplitude of aspiration, in dB\n";
01719   if (glob.afDyn)
01720     outFile <<  "AF   V    0     "<<glob.af<<"    80  Amplitude of frication, in dB\n";
01721   else
01722     outFile <<  "AF   v    0     "<<glob.af<<"    80  Amplitude of frication, in dB\n";
01723   if (glob.f1Dyn)
01724     outFile <<  "F1   V  180   "<<glob.f1<<"  1300  Frequency of 1st formant, in Hz\n";
01725   else
01726     outFile <<  "F1   v  180   "<<glob.f1<<"  1300  Frequency of 1st formant, in Hz\n";
01727   if (glob.b1Dyn) 
01728     outFile <<  "B1   V   30    "<<glob.b1<<"  1000  Bandwidth of 1st formant, in Hz\n";
01729   else
01730     outFile <<  "B1   v   30    "<<glob.b1<<"  1000  Bandwidth of 1st formant, in Hz\n";
01731   if (glob.df1Dyn)
01732     outFile <<  "DF1  V    0     "<<glob.df1<<"   100  Change in F1 during open portion of period, in Hz\n";
01733   else
01734     outFile <<  "DF1  v    0     "<<glob.df1<<"   100  Change in F1 during open portion of period, in Hz\n";
01735   if (glob.db1Dyn)
01736     outFile <<  "DB1  V    0     "<<glob.db1<<"   400  Change in B1 during open portion of period, in Hz\n";
01737   else
01738     outFile <<  "DB1  v    0     "<<glob.db1<<"   400  Change in B1 during open portion of period, in Hz\n";
01739   if (glob.f2Dyn)
01740     outFile <<  "F2   V  550  "<<glob.f2<<"  3000  Frequency of 2nd formant, in Hz\n";
01741   else
01742     outFile <<  "F2   v  550  "<<glob.f2<<"  3000  Frequency of 2nd formant, in Hz\n";
01743   if (glob.b2Dyn)
01744     outFile <<  "B2   V   40   "<<glob.b2<<"  90   Bandwidth of 2nd formant, in Hz\n";
01745   else
01746     outFile <<  "B2   v   40  "<<glob.b2<<"  90    Bandwidth of 2nd formant, in Hz\n";
01747   if (glob.f3Dyn)
01748     outFile <<  "F3   V 1200 "<<glob.f3<<" 2500    Frequency of 3rd formant, in Hz\n";
01749   else 
01750     outFile <<  "F3   v 1200 "<<glob.f3<<"  2500   Frequency of 3rd formant, in Hz\n";
01751   if (glob.b3Dyn)
01752     outFile <<  "B3   V   60  "<<glob.b3<<"   150  Bandwidth of 3rd formant, in Hz\n";
01753   else
01754     outFile <<  "B3   v   60 "<<glob.b3<<"   150   Bandwidth of 3rd formant, in Hz\n";
01755   if (glob.f4Dyn)    
01756     outFile <<  "F4   V 2400  "<<glob.f4<<"  4990  Frequency of 4th formant, in Hz\n";
01757   else
01758     outFile <<  "F4   v 2400  "<<glob.f4<<"  4990  Frequency of 4th formant, in Hz\n";
01759   if (glob.b4Dyn)
01760     outFile <<  "B4   V  100   "<<glob.b4<<"  1000  Bandwidth of 4th formant, in Hz\n";
01761   else
01762     outFile <<  "B4   v  100   "<<glob.b4<<"  1000  Bandwidth of 4th formant, in Hz\n";
01763   if (glob.f5Dyn)
01764     outFile <<  "F5   V 3000  "<<glob.f5<<"  4990  Frequency of 5th formant, in Hz\n";
01765   else
01766     outFile <<  "F5   v 3000  "<<glob.f5<<"  4990  Frequency of 5th formant, in Hz\n";
01767   if (glob.b5Dyn)
01768     outFile <<  "B5   V  100   "<<glob.b5<<"  1500  Bandwidth of 5th formant, in Hz\n";
01769   else
01770     outFile <<  "B5   v  100   "<<glob.b5<<"  1500  Bandwidth of 5th formant, in Hz\n";
01771   if (glob.f6Dyn)
01772     outFile <<  "F6   V 3000  "<<glob.f6<<"  4990  Frequency of 6th formant, in Hz (applies if NF=6)\n";
01773   else
01774     outFile <<  "F6   v 3000  "<<glob.f6<<"  4990  Frequency of 6th formant, in Hz (applies if NF=6)\n";
01775   if (glob.b6Dyn)
01776     outFile <<  "B6   V  100   "<<glob.b6<<"  4000  Bandwidth of 6th formant, in Hz (applies if NF=6)\n";
01777   else
01778     outFile <<  "B6   v  100   "<<glob.b6<<"  4000  Bandwidth of 6th formant, in Hz (applies if NF=6)\n";
01779   if (glob.fnpDyn)
01780     outFile <<  "FNP  V  180   "<<glob.fnp<<"  2000  Frequency of nasal pole, in Hz\n";
01781   else
01782     outFile <<  "FNP  v  180   "<<glob.fnp<<"  2000  Frequency of nasal pole, in Hz\n";
01783   if (glob.bnpDyn)
01784     outFile <<  "BNP  V   40    "<<glob.bnp<<"  1000  Bandwidth of nasal pole, in Hz\n";
01785   else
01786     outFile <<  "BNP  v   40    "<<glob.bnp<<"  1000  Bandwidth of nasal pole, in Hz\n";
01787   if (glob.fnzDyn)
01788     outFile <<  "FNZ  V  180   "<<glob.fnz<<"  2000  Frequency of nasal zero, in Hz\n";
01789   else
01790     outFile <<  "FNZ  v  180   "<<glob.fnz<<"  2000  Frequency of nasal zero, in Hz\n";
01791   if (glob.bnzDyn)
01792     outFile <<  "BNZ  V   40    "<<glob.bnz<<"  1000  Bandwidth of nasal zero, in Hz\n";
01793   else
01794     outFile <<  "BNZ  v   40    "<<glob.bnz<<"  1000  Bandwidth of nasal zero, in Hz\n";
01795   if (glob.ftpDyn)
01796     outFile <<  "FTP  V  300  "<<glob.ftp<<"  3000  Frequency of tracheal pole, in Hz\n";
01797   else
01798     outFile <<  "FTP  v  300  "<<glob.ftp<<"  3000  Frequency of tracheal pole, in Hz\n";
01799   if (glob.btpDyn)
01800     outFile <<  "BTP  V   40   "<<glob.btp<<"  1000  Bandwidth of tracheal pole, in Hz\n";
01801   else
01802     outFile <<  "BTP  v   40   "<<glob.btp<<"  1000  Bandwidth of tracheal pole, in Hz\n";
01803   if (glob.ftzDyn)
01804     outFile <<  "FTZ  V  300  "<<glob.ftz<<"  3000  Frequency of tracheal zero, in Hz\n";
01805   else
01806     outFile <<  "FTZ  v  300  "<<glob.ftz<<"  3000  Frequency of tracheal zero, in Hz\n";
01807   if (glob.btzDyn)
01808     outFile <<  "BTZ  V   40   "<<glob.btz<<"  2000  Bandwidth of tracheal zero, in Hz\n";
01809   else
01810     outFile <<  "BTZ  v   40   "<<glob.btz<<"  2000  Bandwidth of tracheal zero, in Hz\n";
01811   if (glob.a2fDyn)
01812     outFile <<  "A2F  V    0     "<<glob.a2f<<"    80  Amp of fric-excited parallel 2nd formant, in dB\n";
01813   else
01814     outFile <<  "A2F  v    0     "<<glob.a2f<<"    80  Amp of fric-excited parallel 2nd formant, in dB\n";
01815   if (glob.a3fDyn)
01816     outFile <<  "A3F  V    0     "<<glob.a3f<<"    80  Amp of fric-excited parallel 3rd formant, in dB\n";
01817   else
01818     outFile <<  "A3F  v    0     "<<glob.a3f<<"    80  Amp of fric-excited parallel 3rd formant, in dB\n";
01819   if (glob.a4fDyn)
01820     outFile <<  "A4F  V    0     "<<glob.a4f<<"    80  Amp of fric-excited parallel 4th formant, in dB\n";
01821   else
01822     outFile <<  "A4F  v    0     "<<glob.a4f<<"    80  Amp of fric-excited parallel 4th formant, in dB\n";
01823   if (glob.a5fDyn)
01824     outFile <<  "A5F  V    0     "<<glob.a5f<<"    80  Amp of fric-excited parallel 5th formant, in dB\n";
01825   else
01826     outFile <<  "A5F  v    0     "<<glob.a5f<<"    80  Amp of fric-excited parallel 5th formant, in dB\n";
01827   if (glob.a6fDyn)
01828     outFile <<  "A6F  V    0     "<<glob.a6f<<"    80  Amp of fric-excited parallel 6th formant, in dB\n";
01829   else
01830     outFile <<  "A6F  v    0     "<<glob.a6f<<"    80  Amp of fric-excited parallel 6th formant, in dB\n";
01831   if (glob.abDyn)
01832     outFile <<  "AB   V    0     "<<glob.ab<<"    80  Amp of fric-excited parallel bypass path, in dB\n";
01833   else
01834     outFile <<  "AB   v    0     "<<glob.ab<<"    80  Amp of fric-excited parallel bypass path, in dB\n";
01835   if (glob.b2pDyn)
01836     outFile <<  "B2F  V   40   "<<glob.b2p<<"  1000  Bw of fric-excited parallel 2nd formant, in Hz\n";
01837   else
01838     outFile <<  "B2F  v   40   "<<glob.b2p<<"  1000  Bw of fric-excited parallel 2nd formant, in Hz\n";
01839   if (glob.b3pDyn)
01840     outFile <<  "B3F  V   60   "<<glob.b3p<<"  1000  Bw of fric-excited parallel 3rd formant, in Hz\n";
01841   else
01842     outFile <<  "B3F  v   60   "<<glob.b3p<<"  1000  Bw of fric-excited parallel 3rd formant, in Hz\n";
01843   if (glob.b4pDyn)
01844     outFile <<  "B4F  V  100   "<<glob.b4p<<"  1000  Bw of fric-excited parallel 4th formant, in Hz\n";
01845   else
01846     outFile <<  "B4F  v  100   "<<glob.b4p<<"  1000  Bw of fric-excited parallel 4th formant, in Hz\n";
01847   if (glob.b5pDyn)
01848     outFile <<  "B5F  V  100   "<<glob.b5p<<"  1500  Bw of fric-excited parallel 5th formant, in Hz\n";
01849   else
01850     outFile <<  "B5F  v  100   "<<glob.b5p<<"  1500  Bw of fric-excited parallel 5th formant, in Hz\n";
01851   if (glob.b6pDyn)
01852     outFile <<  "B6F  V  100  "<<glob.b6p<<"  4000  Bw of fric-excited parallel 6th formant, in Hz\n";
01853   else
01854     outFile <<  "B6F  v  100  "<<glob.b6p<<"  4000  Bw of fric-excited parallel 6th formant, in Hz\n";
01855   if (glob.anvDyn)
01856     outFile <<  "ANV  V    0     "<<glob.anv<<"    80  Amp of voice-excited parallel nasal form., in dB\n";
01857   else
01858     outFile <<  "ANV  v    0     "<<glob.anv<<"    80  Amp of voice-excited parallel nasal form., in dB\n";
01859   if (glob.a1vDyn)
01860     outFile <<  "A1V  V    0    "<<glob.a1v<<"    80  Amp of voice-excited parallel 1st formant, in dB\n";
01861   else
01862     outFile <<  "A1V  v    0    "<<glob.a1v<<"    80  Amp of voice-excited parallel 1st formant, in dB\n";
01863   if (glob.a2vDyn)
01864     outFile <<  "A2V  V    0    "<<glob.a2v<<"    80  Amp of voice-excited parallel 2nd formant, in dB\n";
01865   else
01866     outFile <<  "A2V  v    0    "<<glob.a2v<<"    80  Amp of voice-excited parallel 2nd formant, in dB\n";
01867   if (glob.a3vDyn)
01868     outFile <<  "A3V  V    0    "<<glob.a3v<<"    80  Amp of voice-excited parallel 3rd formant, in dB\n";
01869   else
01870     outFile <<  "A3V  v    0    "<<glob.a3v<<"    80  Amp of voice-excited parallel 3rd formant, in dB\n";
01871   if (glob.a4vDyn)
01872     outFile <<  "A4V  V    0    "<<glob.a4v<<"    80  Amp of voice-excited parallel 4th formant, in dB\n";
01873   else
01874     outFile <<  "A4V  v    0    "<<glob.a4v<<"    80  Amp of voice-excited parallel 4th formant, in dB\n";
01875   if (glob.atvDyn)
01876     outFile <<  "ATV  V    0     "<<glob.atv<<"    80  Amp of voice-excited par tracheal formant, in dB\n";
01877   else
01878     outFile <<  "ATV  v    0     "<<glob.atv<<"    80  Amp of voice-excited par tracheal formant, in dB\n";
01879   
01880   outFile <<  "\n\n\n\n"; // skip four lines
01881   
01882 
01883   outFile <<  "Varied Parameters:\n";
01884   outFile.width(4);
01885   outFile <<  "time";
01886   if (glob.f0Dyn) outFile << "   F0";
01887   if (glob.avDyn) outFile << "   AV";
01888   if (glob.oqDyn) outFile << "   OQ";
01889   if (glob.sqDyn) outFile << "   SQ";
01890   if (glob.tlDyn) outFile << "   TL";
01891   if (glob.flDyn) outFile << "   FL";
01892   if (glob.diDyn) outFile << "   DI";
01893   if (glob.ahDyn) outFile << "   AH";
01894   if (glob.afDyn) outFile << "   AF";
01895   if (glob.f1Dyn) outFile << "   F1";
01896   if (glob.b1Dyn) outFile << "   B1";
01897   if (glob.df1Dyn) outFile << "   DF1";
01898   if (glob.db1Dyn) outFile << "   DB1";
01899   if (glob.f2Dyn) outFile << "   F2";
01900   if (glob.b2Dyn) outFile << "   B2";
01901   if (glob.f3Dyn) outFile << "   F3";
01902   if (glob.b3Dyn) outFile << "   B3";
01903   if (glob.f4Dyn) outFile << "   F4";
01904   if (glob.b4Dyn) outFile << "   B4";
01905   if (glob.f5Dyn) outFile << "   F5";
01906   if (glob.b5Dyn) outFile << "   B5";
01907   if (glob.f6Dyn) outFile << "   F6";
01908   if (glob.b6Dyn) outFile << "   B6";
01909   if (glob.fnpDyn) outFile << "   FNP";
01910   if (glob.bnpDyn) outFile << "   BNP";
01911   if (glob.fnzDyn) outFile << "   FNZ";
01912   if (glob.bnzDyn) outFile << "   BNZ";
01913   if (glob.ftpDyn) outFile << "   FTP";
01914   if (glob.btpDyn) outFile << "   BTZ";
01915   if (glob.ftzDyn) outFile << "   FTZ";
01916   if (glob.btzDyn) outFile << "   BTZ";
01917   if (glob.a2fDyn) outFile << "   A2F";
01918   if (glob.a3fDyn) outFile << "   A3F";
01919   if (glob.a4fDyn) outFile << "   A4F";
01920   if (glob.a5fDyn) outFile << "   A5F";
01921   if (glob.a6fDyn) outFile << "   A6F";
01922   if (glob.abDyn) outFile << "   AB";
01923   if (glob.b2pDyn) outFile << "   B2F";
01924   if (glob.b3pDyn) outFile << "   B3F";
01925   if (glob.b4pDyn) outFile << "   B4F";
01926   if (glob.b5pDyn) outFile << "   B5F";
01927   if (glob.b6pDyn) outFile << "   B6F";
01928   if (glob.anvDyn) outFile << "   ANV";
01929   if (glob.a1vDyn) outFile << "   A1V";
01930   if (glob.a2vDyn) outFile << "   A2V";
01931   if (glob.a3vDyn) outFile << "   A3V";
01932   if (glob.a4vDyn) outFile << "   A4V";
01933   if (glob.atvDyn) outFile << "   ATV";
01934 
01935   outFile <<  "\n";
01936   for (uint syl=0; syl<syllableVec.size(); syl++) {
01937     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01938       outFile << "# name of phone: "<<syllableVec[syl].PhonVec()[pho].Name()<<"\n";
01939       outFile << "# meaning of params:\n";
01940       outFile << "# time";
01941       if (glob.f0Dyn) outFile << " F0";
01942       if (glob.avDyn) outFile << " AV";
01943       if (glob.oqDyn) outFile << " OQ";
01944       if (glob.sqDyn) outFile << " SQ";
01945       if (glob.tlDyn) outFile << " TL";
01946       if (glob.flDyn) outFile << " FL";
01947       if (glob.diDyn) outFile << " DI";
01948       if (glob.ahDyn) outFile << " AH";
01949       if (glob.afDyn) outFile << " AF";
01950       if (glob.f1Dyn) outFile << " F1";
01951       if (glob.b1Dyn) outFile << " B1";
01952       if (glob.df1Dyn) outFile << " DF1";
01953       if (glob.db1Dyn) outFile << " DB1";
01954       if (glob.f2Dyn) outFile << " F2";
01955       if (glob.b2Dyn) outFile << " B2";
01956       if (glob.f3Dyn) outFile << " F3";
01957       if (glob.b3Dyn) outFile << " B3";
01958       if (glob.f4Dyn) outFile << " F4";
01959       if (glob.b4Dyn) outFile << " B4";
01960       if (glob.f5Dyn) outFile << " F5";
01961       if (glob.b5Dyn) outFile << " B5";
01962       if (glob.f6Dyn) outFile << " F6";
01963       if (glob.b6Dyn) outFile << " B6";
01964       if (glob.fnpDyn) outFile << " FNP";
01965       if (glob.bnpDyn) outFile << " BNP";
01966       if (glob.fnzDyn) outFile << " FNZ";
01967       if (glob.bnzDyn) outFile << " BNZ";
01968       if (glob.ftpDyn) outFile << " FTP";
01969       if (glob.btpDyn) outFile << " BTZ";
01970       if (glob.ftzDyn) outFile << " FTZ";
01971       if (glob.btzDyn) outFile << " BTZ";
01972       if (glob.a2fDyn) outFile << " A2F";
01973       if (glob.a3fDyn) outFile << " A3F";
01974       if (glob.a4fDyn) outFile << " A4F";
01975       if (glob.a5fDyn) outFile << " A5F";
01976       if (glob.a6fDyn) outFile << " A6F";
01977       if (glob.abDyn) outFile << " AB";
01978       if (glob.b2pDyn) outFile << " B2F";
01979       if (glob.b3pDyn) outFile << " B3F";
01980       if (glob.b4pDyn) outFile << " B4F";
01981       if (glob.b5pDyn) outFile << " B5F";
01982       if (glob.b6pDyn) outFile << " B6F";
01983       if (glob.anvDyn) outFile << " ANV";
01984       if (glob.a1vDyn) outFile << " A1V";
01985       if (glob.a2vDyn) outFile << " A2V";
01986       if (glob.a3vDyn) outFile << " A3V";
01987       if (glob.a4vDyn) outFile << " A4V";
01988       if (glob.atvDyn) outFile << " ATV";
01989       outFile <<  "\n";
01990       syllableVec[syl].PhonVec()[pho].printSenSynFrames(start, outFile, glob);
01991       start +=  syllableVec[syl].PhonVec()[pho].FrameNum() * glob.ui;
01992     }
01993   }
01994 }

void phrase::printSyllableVec ( ostream & outFile )
 

prints names of phones to outFile (debugging).

Parameters:
ostream   &outFile
00078                                               {
00079   for (uint i=0; i<syllableVec.size(); i++) {
00080     syllableVec[i].printPhonVec(outFile);
00081     if (syllableVec[i].PhonNum()<4)
00082       outFile << "\t";
00083     outFile << "\taccentType = " << (uint) syllableVec[i].Accent()<<",";
00084     outFile << "\t";
00085     outFile << "avr. f0 = " << syllableVec[i].MeanF0() << "\n";
00086   }
00087 }

void phrase::readF0FromDB ( string diphonBase,
globalsT & glob )
 

assignes only f0-vals.

It's used for resynthesis if you only want to read in the original intonation contour to print it to a new input-file in connection with

See also:
readPhoList()
Parameters:
string   diphonBase, the directory containing the diphone-files.
globalsT   glob, defaultparams for klattsynth
02235                                                            {
02236   
02237   // variable declarations
02238   string actName, nextName, requiredDiphon;
02239   phon *actPhonP, *nextPhonP;
02240   string diphonType;
02241   string buffer;        // tmp-buffer for line in diphon-file
02242   vector<string> bufferVec;
02243   PHON_MANNER actManner;
02244   uint lineCnt=0; // Cnt of lines in diphon-file
02245   vector<uint> diphonFrameNums(0); // list of frameNums foreach diphon
02246 
02247   uint phonBrdFrm; // border frame foreach phon
02248   uint phonFrameNum; // frameNum in database of phon
02249   uint allFrameCnt=0; // help Cnt for assignment of params to phones 
02250 
02251   // vectors for markers in diphons
02252   vector<uint> t1(0), t2(0), border(0);
02253   // t1: first transition, t2: 2. transition
02254   // border between diphones
02255   
02256   vector<uint> tmpF0;
02257 
02258   uint phon=0;
02259   string diphonName;
02260   for (uint syl=0; syl<syllableVec.size(); syl++) {
02261     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
02262 
02263       actPhonP = &syllableVec[syl].PhonVec()[pho];
02264       if (pho==syllableVec[syl].PhonNum()-1)
02265         if (syl==syllableVec.size()-1)
02266           break;
02267         else
02268           nextPhonP = &syllableVec[syl+1].PhonVec()[0];
02269       else
02270         nextPhonP = &syllableVec[syl].PhonVec()[pho+1];
02271 
02272       actName = (*actPhonP).Name();
02273       nextName = (*nextPhonP).Name();
02274 
02275       requiredDiphon = actName + "-" + nextName;
02276       
02277       requiredDiphon = diphonBase + "/" + requiredDiphon + ".dip";
02278       //    cout << requiredDiphon << "\n";
02279       ifstream inFile(requiredDiphon.c_str());
02280       if (inFile.good()) {
02281         lineCnt = 0;
02282         while  (getline(inFile, buffer)) {
02283           if (buffer != "" && buffer.at(0) != '#') {
02284             bufferVec = string2vec(buffer);
02285             if (lineCnt==0) {
02286               diphonName = bufferVec[1];
02287             }
02288             if (lineCnt==1) {
02289               if (bufferVec[0]!="frameNumber") error("error in diphon-file:"+diphonName+"\n",-3);
02290               diphonFrameNums.push_back(atoi(bufferVec[1].c_str()));
02291             }
02292             else if (lineCnt==2) {
02293               if (bufferVec[0]!="t1") error("error in diphon-file:"+diphonName+"\n",-3);
02294               t1.push_back(atoi(bufferVec[1].c_str()));
02295             } else if (lineCnt==3) {
02296               if (bufferVec[0]!="border") error("error in diphon-file:"+diphonName+"\n",-3);
02297               border.push_back(atoi(bufferVec[1].c_str()));
02298             }  else if (lineCnt==4) {
02299               if (bufferVec[0]!="t2") error("error in diphon-file:"+diphonName+"\n",-3);
02300               t2.push_back(atoi(bufferVec[1].c_str()));
02301             }
02302             else if (lineCnt>4) {
02303               tmpF0.push_back(atoi(bufferVec[0].c_str()));
02304             }
02305             lineCnt++;
02306           } // if (buffer != "") 
02307         } // while (getline(inFile, buffer)) 
02308         inFile.close();
02309       } else {
02310         error("can't open diphon-file: " + requiredDiphon + "\n", -1);
02311       } // if (inFile.good())      
02312       phon++;
02313     } // foreach pho
02314   } // foreach syl
02315   
02316   // assign parameters to phones
02317   phon=0;
02318   for (uint syl=0; syl<syllableVec.size(); syl++) {
02319     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
02320       actPhonP = &syllableVec[syl].PhonVec()[pho];
02321       actName = (*actPhonP).Name();
02322       actManner = (*actPhonP).Manner();
02323       
02324       if (!(syl==0 && pho==0) && !(syl==syllableVec.size()-1 && pho==syllableVec[syl].PhonNum()-1) ) {  
02325         //if (actManner == silence) { 
02326           // phonFrameNums.push_back(0);
02327         //} else 
02328           if (actManner != stop_voiced && actManner != stop_voiceless) {
02329           // first phon should always be silence
02330           if (phon==0) error("you've found a bug!!!\n",-50); 
02331           // cout << actName <<" " << diphonFrameNums[phon-1]-border[phon-1]+border[phon] <<"\n";
02332           phonFrameNum = diphonFrameNums[phon-1] - border[phon-1] + border[phon];
02333           phonBrdFrm = diphonFrameNums[phon-1]-border[phon-1];
02334           (*actPhonP).setSteadyStart(t2[phon-1] - border[phon-1]);
02335           (*actPhonP).setSteadyEnd(diphonFrameNums[phon-1] - border[phon-1] + t1[phon]);
02336           // cout << actName <<" "<<phonFrameNum<<"\n";
02337         } else { // phon is stop
02338           //     cout << actName <<" " << diphonFrameNums[phon-1]-border[phon-1]+border[phon]<<"\n";
02339           phonFrameNum = diphonFrameNums[phon-1] - border[phon-1] + border[phon];
02340           phonBrdFrm = diphonFrameNums[phon-1]-border[phon-1];
02341         }
02342         
02343         // copy original params
02344           //        if (actManner != silence) {
02345           
02346           vector<uint> actTmpF0(0);
02347           
02348           for (uint phonFrameCnt=0; phonFrameCnt < phonFrameNum; phonFrameCnt++) {
02349             actTmpF0.push_back(tmpF0[allFrameCnt]);
02350             allFrameCnt++;
02351           } // for (uint phonFrameCnt=0; phonFrameCnt<phonFrameNum; phonFrameCnt++)
02352           
02353           // check diphonborders for big freq-jumps
02354           
02355           // fill param vectors
02356           (*actPhonP).setF0Vec(actTmpF0, glob);  
02357           
02358           //}
02359       }
02360       phon++;
02361     } // foreach pho
02362   }  // foreach syl
02363 }

void phrase::readPhoFile ( istream & inFile,
globalsT & kg )
 

reads in phones for syllables from inFile.

the format of the pho-file is as followed:

  • comments are started by a '#' as first char of line
  • syllable-borders are denoted by a single '-' as first char of line, followed by an integer denoting the accent-type: 0 for none, 1 for word-accent, 2 for sentence-accent
  • feature-flags have the syntax: <flag> <time of occurance in msec>
  • possible feature-flags are: +/- voc, brt, nas, lar, spr for voiced, breathy, nasalized, laryngealized, spread respectively these features can be valid in regions and are followed by a time value +rounded, +overshoot, +undershoot for the corresponding vowel qualities these features are valid for the whole phone
  • phone descriptors follow the mbrola-syntax: <name> <duration in msec> <intonation description>.
    Parameters:
    istream   &inFile
    00266                                                         {
    00267   string buffer;
    00268   //  phon tmpPhon;
    00269   string name;
    00270   const string syllableSeperator = "-";
    00271   int dur;
    00272   syllable tmpSyl;
    00273   vector<uint> tmpF0ValVec(0);
    00274   vector<uint> tmpF0TimeVec(0);
    00275   PHON_FEATURES tmpPhonFeatures;
    00276 
    00277   initPhonFeatures(tmpPhonFeatures);
    00278 
    00279   while (getline(inFile, buffer)) {
    00280 
    00281     // a valid line in a pho-file is either a comment
    00282     if (buffer != "" && buffer.at(0) != '#') {
    00283       vector<string> tokenVec;
    00284       tokenVec = string2vec(buffer);
    00285       
    00286       
    00287       // or a syllable-separator
    00288      if (tokenVec[0] == syllableSeperator) { // this is a syllable border
    00289        // read the accent-type
    00290        if (tokenVec.size()>1) {
    00291          tmpSyl.setAccent((ACCENT_TYPE) atoi(tokenVec[1].c_str()));
    00292        } else {
    00293          error("phrase::readPhoFile: missing accentType in phon-feature near phon "+name+"\n", -3);
    00294        }
    00295         // push the last phonFeatures
    00296         phon *tmpPhonP;
    00297         tmpPhonP = &tmpSyl.PhonVec()[tmpSyl.PhonNum()-1];
    00298         (*tmpPhonP).setPhonFeatures(tmpPhonFeatures);
    00299         initPhonFeatures(tmpPhonFeatures);
    00300         tmpSyl.calcMeanF0();
    00301         // push the syllable
    00302         syllableVec.push_back(tmpSyl);
    00303         // clear the tmp-syllable
    00304         tmpSyl.clearPhonVec();
    00305         
    00306         // or a feature-flag
    00307      } else if (tokenVec[0] == "+voc") {
    00308         if (tokenVec.size()>1) {
    00309           tmpPhonFeatures.vocStart = msec2frames(atoi(tokenVec[1].c_str()), glob);
    00310         } else 
    00311           error("phrase::readPhoFile: missing parameter in phon-feature near phon "+name+"\n", -3);     
    00312         if (!tmpPhonFeatures.voiced)
    00313           tmpPhonFeatures.vocStop = A_HIGH_INT;
    00314         tmpPhonFeatures.voiced = true;
    00315       } else if (tokenVec[0] == "-voc") {
    00316         if (!tmpPhonFeatures.voiced)
    00317           tmpPhonFeatures.vocStart = 0;
    00318         if (tokenVec.size()>1) {
    00319           tmpPhonFeatures.vocStop = msec2frames(atoi(tokenVec[1].c_str()), glob);
    00320         } else 
    00321           error("phrase::readPhoFile: missing parameter in phon-feature near phon "+name+"\n", -3);
    00322         tmpPhonFeatures.voiced = true;
    00323       } else if (tokenVec[0] == "+brt") {
    00324         if (tokenVec.size()>2) {
    00325           tmpPhonFeatures.brtStart = msec2frames(atoi(tokenVec[1].c_str()), glob);
    00326           tmpPhonFeatures.brtRate = atoi(tokenVec[2].c_str());    
    00327         } else 
    00328           error("phrase::readPhoFile: missing parameter in phon-feature near phon "+name+"\n", -3);
    00329         tmpPhonFeatures.brtStop = A_HIGH_INT;
    00330         tmpPhonFeatures.breathy = true;
    00331       } else if (tokenVec[0] == "-brt") {
    00332         if (!tmpPhonFeatures.breathy)
    00333           tmpPhonFeatures.brtStart = 0;
    00334         if (tokenVec.size()>1) {
    00335           tmpPhonFeatures.brtStop = msec2frames(atoi(tokenVec[1].c_str()), glob);
    00336           if (!tmpPhonFeatures.breathy) { // if it's not allready breathy, get rate
    00337             if (tokenVec.size()>2)     
    00338               tmpPhonFeatures.brtRate = atoi(tokenVec[2].c_str());      
    00339             else 
    00340               error("phrase::readPhoFile: missing parameter in phon-feature near phon "+name+"\n", -3);
    00341           }
    00342         } else 
    00343           error("phrase::readPhoFile: missing parameter in phon-feature near phon "+name+"\n", -3);
    00344         tmpPhonFeatures.breathy = true;
    00345       } else if (tokenVec[0] == "+nas") {
    00346         if (tokenVec.size()>1) {
    00347         tmpPhonFeatures.nasStart = msec2frames(atoi(tokenVec[1].c_str()), glob);
    00348         } else 
    00349           error("phrase::readPhoFile: missing parameter in phon-feature near phon "+name+"\n", -3);
    00350         tmpPhonFeatures.nasStop = A_HIGH_INT;
    00351         tmpPhonFeatures.nasalized = true;
    00352       } else if (tokenVec[0] == "-nas") {
    00353         if (!tmpPhonFeatures.nasalized)
    00354           tmpPhonFeatures.nasStart = 0;
    00355         if (tokenVec.size()>1) {
    00356           tmpPhonFeatures.nasStop = msec2frames(atoi(tokenVec[1].c_str()), glob);
    00357         } else 
    00358           error("phrase::readPhoFile: missing parameter in phon-feature near phon "+name+"\n", -3);
    00359         tmpPhonFeatures.nasalized = true;
    00360       } else if (tokenVec[0] == "+lar") {
    00361         if (tokenVec.size()>2) {
    00362           tmpPhonFeatures.larStart = msec2frames(atoi(tokenVec[1].c_str()), glob);
    00363           tmpPhonFeatures.larRate = atoi(tokenVec[2].c_str());
    00364         } else 
    00365           error("phrase::readPhoFile: missing parameter in phon-feature near phon "+name+"\n", -3);
    00366         tmpPhonFeatures.larStop = A_HIGH_INT;
    00367         tmpPhonFeatures.laryngealized = true;
    00368       } else if (tokenVec[0] == "-lar") {
    00369         if (!tmpPhonFeatures.laryngealized)
    00370           tmpPhonFeatures.larStart = 0;
    00371         if (tokenVec.size()>1) {
    00372           tmpPhonFeatures.larStop = msec2frames(atoi(tokenVec[1].c_str()), glob);
    00373           if (!tmpPhonFeatures.laryngealized) {
    00374             if (tokenVec.size()>2) 
    00375               tmpPhonFeatures.larRate = atoi(tokenVec[2].c_str());
    00376             else 
    00377               error("phrase::readPhoFile: missing parameter in phon-feature near phon "+name+"\n", -3);  
    00378           }  
    00379         } else 
    00380           error("phrase::readPhoFile: missing parameter in phon-feature near phon "+name+"\n", -3);
    00381         tmpPhonFeatures.laryngealized = true;
    00382 
    00383       } else if (tokenVec[0] == "+spr") {
    00384         if (tokenVec.size()>1) {
    00385           tmpPhonFeatures.spreadRate = atoi(tokenVec[1].c_str());
    00386         } else 
    00387           error("phrase::readPhoFile: missing parameter in phon-feature near phon "+name+"\n", -3);
    00388         tmpPhonFeatures.spread = true;
    00389       } else if (tokenVec[0] == "+rounded") {
    00390         if (tokenVec.size()>1) {
    00391           tmpPhonFeatures.roundedRate = atoi(tokenVec[1].c_str());
    00392         } else 
    00393           error("phrase::readPhoFile: missing parameter in phon-feature near phon "+name+"\n", -3);
    00394         tmpPhonFeatures.rounded = true; 
    00395       } else if (tokenVec[0] == "+tense") {
    00396         tmpPhonFeatures.tense = true;
    00397         if (tokenVec.size()>1) {
    00398           tmpPhonFeatures.tenseRate = atoi(tokenVec[1].c_str());
    00399         } else 
    00400           error("phrase::readPhoFile: missing parameter in phon-feature near phon "+name+"\n", -3);
    00401         
    00402       } else if (tokenVec[0] == "+falsett") {
    00403         tmpPhonFeatures.falsett = true;
    00404         if (tokenVec.size()>1) {
    00405           tmpPhonFeatures.falsettRate = atoi(tokenVec[1].c_str());
    00406         } else 
    00407           error("phrase::readPhoFile: missing parameter in phon-feature near phon "+name+"\n", -3);
    00408         
    00409       } else if (tokenVec[0] == "+whisper") {
    00410         tmpPhonFeatures.whisper = true;
    00411         if (tokenVec.size()>1) {
    00412           tmpPhonFeatures.whisperRate = atoi(tokenVec[1].c_str());
    00413         } else 
    00414           error("phrase::readPhoFile: missing parameter in phon-feature near phon "+name+"\n", -3);
    00415 
    00416       } else if (tokenVec[0] == "+lax") {
    00417         tmpPhonFeatures.lax = true;
    00418       } else if (tokenVec[0] == "-undershoot") {
    00419         tmpPhonFeatures.undershoot = true;
    00420         if (tokenVec.size()>1) {
    00421           tmpPhonFeatures.undershootRate = atoi(tokenVec[1].c_str());
    00422         } else 
    00423           error("phrase::readPhoFile: missing parameter in phon-feature near phon "+name+"\n", -3);
    00424 
    00425       } else if (tokenVec[0] == "+overshoot") {
    00426         tmpPhonFeatures.overshoot = true;
    00427         if (tokenVec.size()>1) {
    00428           tmpPhonFeatures.overshootRate = atoi(tokenVec[1].c_str());
    00429         } else 
    00430           error("phrase::readPhoFile: missing parameter in phon-feature near phon "+name+"\n", -3);
    00431 
    00432         // or a valid pho-file line is a phone-description
    00433       } else {
    00434         name = tokenVec[0];
    00435         if (tokenVec.size() > 1) {      
    00436           dur = atoi(tokenVec[1].c_str());
    00437         } else {
    00438           error("phrase::readPhoFile: no duration at phon "+name+" \n",-1);
    00439         }
    00440         if ((tokenVec.size()-2)%2 == 0) {
    00441           for (uint i=2; i<tokenVec.size(); i=i+2) {
    00442             tmpF0TimeVec.push_back(atoi(tokenVec[i].c_str()));
    00443             // we get f0Vals in 10ths of herz
    00444             tmpF0ValVec.push_back(atoi(tokenVec[i+1].c_str())*10);          
    00445           }
    00446         } else {
    00447           error("phrase::readPhoFile: error in intonation description at phon "+name+" \n",-1);
    00448         }
    00449         phon tmpPhon(name, dur, glob);
    00450         tmpPhon.setF0ValVec(tmpF0ValVec);
    00451         tmpPhon.setF0TimeVec(tmpF0TimeVec);
    00452         tmpPhon.modelIntonation(glob);
    00453         
    00454         tmpF0ValVec.erase(tmpF0ValVec.begin(), tmpF0ValVec.end());
    00455         tmpF0TimeVec.erase(tmpF0TimeVec.begin(), tmpF0TimeVec.end());
    00456         
    00457         tmpSyl.addPhon(tmpPhon);
    00458         if (tmpSyl.PhonNum()>1) {
    00459           phon *tmpPhonP;
    00460           tmpPhonP = &tmpSyl.PhonVec()[tmpSyl.PhonNum()-2];
    00461           (*tmpPhonP).setPhonFeatures(tmpPhonFeatures);
    00462         } else
    00463           tmpPhon.setPhonFeatures(tmpPhonFeatures);
    00464         
    00465         initPhonFeatures(tmpPhonFeatures);
    00466       }
    00467     } // if no comment or empty line
    00468   } // while (getline(inFile, buffer))
    00469   calcDur();
    00470 }
    

void phrase::readPhoList ( istream & inFile,
globalsT & kg )
 

assignes only names of phones and syllable borders.

It's used for resynthesis if you only want to read in the original intonation contour to print it to a new input-file in connection with

See also:
readF0FromDB()
Parameters:
istream   inFile
globalsT   glob
00472                                                         {
00473   string buffer;
00474   //  phon tmpPhon;
00475   string name;
00476   const string syllableSeperator = "-";
00477   syllable tmpSyl;
00478   
00479   while (getline(inFile, buffer)) {
00480     
00481     // a valid line in a pho-file is either a comment
00482     if (buffer != "" && buffer.at(0) != '#') {
00483       vector<string> tokenVec;
00484       tokenVec = string2vec(buffer);
00485       
00486       
00487       // or a syllable-separator
00488       if (tokenVec[0] == syllableSeperator) { // this is a syllable border
00489         // read the accent-type
00490         if (tokenVec.size()>1) {
00491           tmpSyl.setAccent((ACCENT_TYPE) atoi(tokenVec[1].c_str()));
00492         } else {
00493           error("phrase::readPhoFile: missing accentType in phon-feature near phon "+name+"\n", -3);
00494         }
00495         // push the syllable
00496         syllableVec.push_back(tmpSyl);
00497         // clear the tmp-syllable
00498         tmpSyl.clearPhonVec();
00499         
00500         // or a valid pho-file line is a phone-description
00501       } else {
00502         name = tokenVec[0];
00503         phon tmpPhon(name, 0, glob);
00504       
00505         tmpSyl.addPhon(tmpPhon);
00506       }
00507       
00508     } // if no comment or empty line
00509   } // while (getline(inFile, buffer))
00510 }

void phrase::readPhonData ( string diphonBase,
globalsT & glob )
 

reads in amplitudes, formantfreqs and formantbandwidths from diphon-database.

It depends on flags whether there are 3 or 5 formantfreqs dynamic. It assignes f0-vals to frames as well as markers for steady state or time of burst.

See also:
globalsT

Todo:
write more methods to readin the formanttrack data, e.g for whole words, demisylables or whatever.

write better code or even think of a more elegant way to readin the information.

write a method that generates formanttracks from rules.

Parameters:
string   diphonBase, the directory containing the diphone-files.
globalsT   glob, defaultparams for klattsynth
01995                                                            {
01996   
01997   // variable declarations
01998   string actName, nextName, requiredDiphon;
01999   int actFrameNum, actBurstStart, actAspStart;
02000 
02001   phon *actPhonP, *nextPhonP;
02002   string diphonType;
02003   string buffer;        // tmp-buffer for line in diphon-file
02004   vector<string> bufferVec;
02005   PHON_MANNER actManner;
02006   uint lineCnt=0; // Cnt of lines in diphon-file
02007   vector<uint> diphonFrameNums(0); // list of frameNums foreach diphon
02008 
02009   uint phonBrdFrm; // border frame foreach phon
02010   uint phonFrameNum; // frameNum in database of phon
02011   uint allFrameCnt=0; // help Counter for assignment of params to phones 
02012 
02013   // vectors for markers in diphons
02014   vector<uint> t1(0), t2(0), border(0);
02015   // t1: first transition, t2: 2. transition
02016   // border between diphones
02017   
02018   vector<uint> tmpF0;
02019   vector<uint> tmpAmp;
02020   vector<uint> tmpF1, tmpF2, tmpF3, tmpF4, tmpF5;
02021  
02022   // borders for shortening of phones 
02023   int leftBorder, rightBorder;
02024   uint burstStart, aspStart;
02025 
02026   uint phon=0;
02027   string diphonName;
02028   for (uint syl=0; syl<syllableVec.size(); syl++) {
02029     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
02030 
02031       actPhonP = &syllableVec[syl].PhonVec()[pho];
02032       if (pho==syllableVec[syl].PhonNum()-1)
02033         if (syl==syllableVec.size()-1)
02034           break;
02035         else
02036           nextPhonP = &syllableVec[syl+1].PhonVec()[0];
02037       else
02038         nextPhonP = &syllableVec[syl].PhonVec()[pho+1];
02039 
02040       actName = (*actPhonP).Name();
02041       actFrameNum = (*actPhonP).FrameNum();
02042 
02043       nextName = (*nextPhonP).Name();      
02044       requiredDiphon = actName + "-" + nextName;
02045       requiredDiphon = diphonBase + "/" + requiredDiphon + ".dip";
02046       ifstream inFile(requiredDiphon.c_str());
02047       if (inFile.good()) {
02048         lineCnt = 0;
02049         while  (getline(inFile, buffer)) {
02050           if (buffer != "" && buffer.at(0) != '#') {
02051             bufferVec = string2vec(buffer);
02052             if (lineCnt==0) {
02053               diphonName = bufferVec[1];
02054             }
02055             if (lineCnt==1) {
02056               if (bufferVec[0]!="frameNumber") error("error in diphon-file:"+diphonName+"\n",-3);
02057               diphonFrameNums.push_back(atoi(bufferVec[1].c_str()));
02058             }
02059             else if (lineCnt==2) {
02060               if (bufferVec[0]!="t1") error("error in diphon-file:"+diphonName+"\n",-3);
02061               t1.push_back(atoi(bufferVec[1].c_str()));
02062             } else if (lineCnt==3) {
02063               if (bufferVec[0]!="border") error("error in diphon-file:"+diphonName+"\n",-3);
02064               border.push_back(atoi(bufferVec[1].c_str()));
02065             }  else if (lineCnt==4) {
02066               if (bufferVec[0]!="t2") error("error in diphon-file:"+diphonName+"\n",-3);
02067               t2.push_back(atoi(bufferVec[1].c_str()));
02068             }
02069             else if (lineCnt>4) {
02070               tmpF0.push_back(atoi(bufferVec[0].c_str()));
02071               tmpAmp.push_back(atoi(bufferVec[1].c_str()));
02072               tmpF1.push_back(atoi(bufferVec[2].c_str()));
02073               tmpF2.push_back(atoi(bufferVec[3].c_str()));
02074               tmpF3.push_back(atoi(bufferVec[4].c_str()));
02075               if (glob.use4Freq || glob.use5Freq) {
02076                 tmpF4.push_back(atoi(bufferVec[5].c_str()));
02077               }
02078               if (glob.use5Freq) {
02079                 tmpF5.push_back(atoi(bufferVec[6].c_str()));
02080               }
02081             }
02082             lineCnt++;
02083           } // if (buffer != "") 
02084         } // while (getline(inFile, buffer)) 
02085         inFile.close();
02086       } else {
02087         error("can't open diphon-file: " + requiredDiphon + "\n", -1);
02088       } // if (inFile.good())      
02089       phon++;
02090     } // foreach pho
02091   } // foreach syl
02092   
02093   // assign parameters to phones
02094   phon=0;
02095   for (uint syl=0; syl<syllableVec.size(); syl++) {
02096     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
02097       actPhonP = &syllableVec[syl].PhonVec()[pho];
02098       actName = (*actPhonP).Name();
02099       actFrameNum = (*actPhonP).FrameNum();
02100       
02101       actManner = (*actPhonP).Manner();
02102       
02103       if (!(syl==0 && pho==0) && !(syl==syllableVec.size()-1 && pho==syllableVec[syl].PhonNum()-1) ) {  
02104         if (actManner != stop_voiced && actManner != stop_voiceless) {
02105           // first phon should always be silence
02106           if (phon==0) error("you've found a bug!!!\n",-50); 
02107           phonFrameNum = diphonFrameNums[phon-1] - border[phon-1] + border[phon];
02108           phonBrdFrm = diphonFrameNums[phon-1]-border[phon-1];
02109           (*actPhonP).setSteadyStart(t2[phon-1] - border[phon-1]);
02110           (*actPhonP).setSteadyEnd(diphonFrameNums[phon-1] - border[phon-1] + t1[phon]);
02111           
02112         } else { // phon is stop
02113           phonFrameNum = diphonFrameNums[phon-1] - border[phon-1] + border[phon];
02114           phonBrdFrm = diphonFrameNums[phon-1]-border[phon-1];
02115           burstStart = diphonFrameNums[phon-1] - border[phon-1];
02116           aspStart = diphonFrameNums[phon-1] - border[phon-1] + t1[phon];
02117           // cout << actName<<" "<<phonFrameNum<<" "<<burstStart<<" "<<aspStart<<"\n";
02118         }
02119         
02120         // copy original params
02121         
02122         if (actManner != silence || glob.copysynthesis==true) {
02123           vector<uint> actTmpAmp(0), actTmpF1(0), actTmpF2(0), 
02124             actTmpF3(0), actTmpF4(0), 
02125             actTmpF5(0);
02126           
02127           for (uint phonFrameCnt=0; phonFrameCnt < phonFrameNum; phonFrameCnt++) {
02128             actTmpAmp.push_back(tmpAmp[allFrameCnt]);
02129             actTmpF1.push_back(tmpF1[allFrameCnt]);
02130             actTmpF2.push_back(tmpF2[allFrameCnt]);
02131             actTmpF3.push_back(tmpF3[allFrameCnt]);
02132             if (glob.use4Freq || glob.use5Freq)
02133               actTmpF4.push_back(tmpF4[allFrameCnt]);
02134             if (glob.use5Freq) 
02135               actTmpF5.push_back(tmpF5[allFrameCnt]);
02136 
02137             allFrameCnt++;
02138           } // for (uint phonFrameCnt=0; phonFrameCnt<phonFrameNum; phonFrameCnt++)
02139           // check diphonborders for big freq-jumps
02140           if (phonBrdFrm!=0 && phonBrdFrm!=phonFrameNum) {
02141             if ((uint)abs((int)(actTmpF1[phonBrdFrm-1]-actTmpF1[phonBrdFrm]))>jumpTolerance && ! glob.warningsOff)
02142               cerr<<"WARNING: readPhonData: big freq jump ("<<abs((int)(actTmpF1[phonBrdFrm-1]-actTmpF1[phonBrdFrm]))<<") for f1 at phon "<<actName<<"\n";
02143             if ((uint)abs((int)(actTmpF2[phonBrdFrm-1]-actTmpF2[phonBrdFrm]))>jumpTolerance && ! glob.warningsOff)
02144               cerr<<"WARNING: readPhonData: big freq jump ("<<abs((int)(actTmpF2[phonBrdFrm-1]-actTmpF2[phonBrdFrm]))<<") for f2 at phon "<<actName<<"\n";
02145             if ((uint)abs((int)(actTmpF3[phonBrdFrm-1]-actTmpF3[phonBrdFrm]))>jumpTolerance && ! glob.warningsOff)
02146               cerr<<"WARNING: readPhonData: big freq jump ("<<abs((int)(actTmpF3[phonBrdFrm-1]-actTmpF3[phonBrdFrm]))<<") for f3 at phon "<<actName<<"\n";
02147           }
02148           
02149           // fill param vectors
02150           if (glob.changeDurMethod == STEADY_STATE_CUT || (actManner==stop_voiced || actManner==stop_voiceless)) {
02151             if (actManner != stop_voiced && actManner != stop_voiceless) {
02152               leftBorder = (*actPhonP).SteadyStart();
02153               rightBorder = (*actPhonP).SteadyEnd(); 
02154             } else { // act phon is stop
02155               leftBorder = 0; 
02156               rightBorder =  burstStart;
02157             }
02158             // cout << actName<<" "<<(*actPhonP).FrameNum()<<" "<<leftBorder<<" "<<rightBorder<<" "<<phonFrameNum<<"\n";
02159             (*actPhonP).setAmpVec(change_valNum((*actPhonP).Name(), (*actPhonP).FrameNum(), leftBorder, rightBorder, actTmpAmp), glob);  
02160             (*actPhonP).setF1Vec(change_valNum((*actPhonP).Name(), (*actPhonP).FrameNum(), leftBorder, rightBorder, actTmpF1), glob);
02161             (*actPhonP).setF2Vec(change_valNum((*actPhonP).Name(), (*actPhonP).FrameNum(), leftBorder, rightBorder, actTmpF2), glob);
02162             (*actPhonP).setF3Vec(change_valNum((*actPhonP).Name(), (*actPhonP).FrameNum(), leftBorder, rightBorder, actTmpF3), glob);
02163             if (glob.use4Freq || glob.use5Freq) 
02164               (*actPhonP).setF4Vec(change_valNum((*actPhonP).Name(), (*actPhonP).FrameNum(), leftBorder, rightBorder, actTmpF4), glob);
02165             if (glob.use5Freq)
02166               (*actPhonP).setF5Vec(change_valNum((*actPhonP).Name(), (*actPhonP).FrameNum(), leftBorder, rightBorder, actTmpF5), glob);
02167           } else { //  changeDurMethod == TIME_ALIGNED
02168             vector<uint> tmpTimeVec;
02169             for (uint i=0; i<phonFrameNum; i++)
02170               tmpTimeVec.push_back(i*(100/phonFrameNum));
02171             (*actPhonP).setAmpVec(modelTrack((*actPhonP).Name(), (*actPhonP).FrameNum(), actTmpAmp, tmpTimeVec), glob);  
02172             (*actPhonP).setF1Vec(modelTrack((*actPhonP).Name(), (*actPhonP).FrameNum(), actTmpF1, tmpTimeVec), glob);
02173             (*actPhonP).setF2Vec(modelTrack((*actPhonP).Name(), (*actPhonP).FrameNum(), actTmpF2, tmpTimeVec), glob);
02174             (*actPhonP).setF3Vec(modelTrack((*actPhonP).Name(), (*actPhonP).FrameNum(), actTmpF3, tmpTimeVec), glob);
02175             if (glob.use4Freq || glob.use5Freq) 
02176               (*actPhonP).setF4Vec(modelTrack((*actPhonP).Name(), (*actPhonP).FrameNum(), actTmpF4, tmpTimeVec), glob);
02177             if (glob.use5Freq)
02178               (*actPhonP).setF5Vec(modelTrack((*actPhonP).Name(), (*actPhonP).FrameNum(), actTmpF5, tmpTimeVec), glob);
02179 
02180           }
02181           if (actManner == stop_voiced || actManner == stop_voiceless) { 
02182             // cout <<actName<<": bS:"<<burstStart<<", aS:"<<aspStart<<"\n";
02183             if (glob.copysynthesis) {
02184               if (burstStart < (phonFrameNum-actFrameNum)) {
02185                 actBurstStart = 0;
02186                 actAspStart = aspStart - burstStart;
02187               } else { 
02188                 actBurstStart = burstStart - (phonFrameNum-actFrameNum);
02189                 actAspStart = aspStart - (phonFrameNum-actFrameNum);
02190               }
02191             } else {
02192               if (actFrameNum>=2) {
02193                 actBurstStart = actFrameNum-2;
02194                 actAspStart = actFrameNum-1;            
02195               } else if (actFrameNum==1) {
02196                 actBurstStart = 0;
02197                 actAspStart = 1;                
02198               } else {
02199                 actBurstStart = 0;
02200                 actAspStart = 0;                
02201               }
02202             }
02203             (*actPhonP).setBurstStart(actBurstStart);
02204             (*actPhonP).setAspStart(actAspStart);
02205             // cout <<actName<<", bS:"<<actBurstStart<<", aS: "<<actAspStart<<", frameLength: "<<actFrameNum<<", dataBaseLength: "<<phonFrameNum<<"\n";
02206             
02207           }
02208           
02209         } else {
02210           // for silent parts interpolate the formant tracks to avoid freq-jumps
02211           uint startF1=tmpF1[allFrameCnt-1]; uint endF1=tmpF1[allFrameCnt];
02212           (*actPhonP).setF1Vec(interpolateLinear((*actPhonP).FrameNum(), startF1, endF1), glob);
02213           uint startF2=tmpF2[allFrameCnt-1]; uint endF2=tmpF2[allFrameCnt];
02214           (*actPhonP).setF2Vec(interpolateLinear((*actPhonP).FrameNum(), startF2, endF2), glob);
02215           uint startF3=tmpF3[allFrameCnt-1]; uint endF3=tmpF3[allFrameCnt];
02216           (*actPhonP).setF3Vec(interpolateLinear((*actPhonP).FrameNum(), startF3, endF3), glob);
02217         } // if (actManner != silence)
02218       }
02219       if (syl==syllableVec.size()-1 && pho==syllableVec[syl].PhonNum()-1) {
02220         // for silence at end continue formant-tracks to avoid freq-jumps
02221         // cout <<tmpF1[allFrameCnt-1]<<"\n";
02222         uint startF1=tmpF1[allFrameCnt-1]; 
02223         (*actPhonP).setF1Vec(interpolateLinear((*actPhonP).FrameNum(), startF1, startF1), glob);
02224         uint startF2=tmpF2[allFrameCnt-1]; 
02225         (*actPhonP).setF2Vec(interpolateLinear((*actPhonP).FrameNum(), startF2, startF2), glob);
02226         uint startF3=tmpF3[allFrameCnt-1];
02227         (*actPhonP).setF3Vec(interpolateLinear((*actPhonP).FrameNum(), startF3, startF3), glob);
02228       }
02229       phon++;
02230     } // foreach pho
02231   }  // foreach syl
02232 }

void phrase::rounded ( uint rate,
globalsT glob )
 

adds rounded Lips characteristices.

All formants get lowered acording to rate.

Todo:
find a better model for rounded lips characteristics.
Parameters:
uint   rate
globalsT   glob, defaultparams for klattsynth
01380                                              {
01381   phon *pP;
01382   for (uint syl=0; syl<syllableVec.size(); syl++) {
01383     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01384       pP = &syllableVec[syl].PhonVec()[pho];
01385       if ((*pP).Type() == vowel) {
01386         PHON_FEATURES tmpPhonFeatures= (*pP).PhonFeatures();
01387         tmpPhonFeatures.rounded = true;
01388         tmpPhonFeatures.roundedRate = rate;       
01389         (*pP).setPhonFeatures(tmpPhonFeatures);
01390       }
01391     }
01392   }     
01393   if (glob.verbose)
01394     cerr <<"added lip-rounding at rate: "<<rate<<"\n";
01395 }

void phrase::smootheF0 ( uint winsize,
globalsT glob )
 

smoothing function: all f0Vals get centerFiltered around winsize.

See also:
phon::smootheF0()
Parameters:
uint   winsize
globalsT   glob, defaultparams for klattsynth
00781                                                   {
00782   for (uint syl=0; syl<syllableVec.size(); syl++) {
00783     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
00784       if (syllableVec[syl].PhonVec()[pho].Voiced() && syllableVec[syl].PhonVec()[pho].Manner() != stop_voiced) {
00785         syllableVec[syl].PhonVec()[pho].smootheF0(winsize);
00786       }
00787     }
00788   }
00789   if (glob.verbose)
00790     cerr << "smoothing f0 with winSize: "<<winsize<<"\n";
00791 }

void phrase::spread ( uint rate,
globalsT glob )
 

adds spread Lips characteristices.

The first 2 formants get shifted upwards according to rate.

Parameters:
uint   rate
globalsT   glob, defaultparams for klattsynth
01363                                             {
01364   phon *pP;
01365   for (uint syl=0; syl<syllableVec.size(); syl++) {
01366     for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01367       pP = &syllableVec[syl].PhonVec()[pho];
01368       if ((*pP).Type()==vowel) {
01369         PHON_FEATURES tmpPhonFeatures= (*pP).PhonFeatures();
01370         tmpPhonFeatures.spread = true;
01371         tmpPhonFeatures.spreadRate = rate;        
01372         (*pP).setPhonFeatures(tmpPhonFeatures);
01373       }
01374     }
01375   }     
01376   if (glob.verbose)
01377     cerr <<"added lip-spreading at rate: "<<rate<<"\n";
01378 }

void phrase::undershootVowels ( ACCENT_TYPE accent,
uint rate,
globalsT glob )
 

blur the vowel precision.

all formantVals in f1 and f2 of vowels in syllables with get displaced towards the center freqencies by subtracting the percentage by <rate> and distance to center frequency.

Parameters:
ACCENT_TYPE   accent
uint   rate
globalsT   glob, defaultparams for klattsynth
01345                                                                           {
01346   phon *pP;
01347   for (uint syl=0; syl<syllableVec.size(); syl++) {
01348     if (syllableVec[syl].Accent()==accent) {
01349       for (uint pho=0; pho<syllableVec[syl].PhonNum(); pho++) {
01350         pP = &syllableVec[syl].PhonVec()[pho];
01351         if ((*pP).Type() == vowel) {
01352           PHON_FEATURES tmpPhonFeatures= (*pP).PhonFeatures();
01353           tmpPhonFeatures.undershoot = true;
01354           tmpPhonFeatures.undershootRate = rate;          
01355           (*pP).setPhonFeatures(tmpPhonFeatures);
01356         }
01357       }
01358     }
01359   }     
01360   if (glob.verbose)
01361     cerr <<"added undershoot at rate: "<<rate<<" for accent-type: "<<(uint)accent<<"\n";
01362 }


Member Data Documentation

uint phrase::dur [private]
 

uint phrase::meanF0 [private]
 

vector< syllable > phrase::syllableVec [private]
 


The documentation for this class was generated from the following files: generated by doxygen