public Vector<MBROLAPhoneme> convertSampa(MBROLAPhoneme maryPhoneme){
  Vector<MBROLAPhoneme> phones=new Vector<MBROLAPhoneme>();
  String marySampa=maryPhoneme.getSymbol();
  if (sampa2voiceMap != null && sampa2voiceMap.containsKey(marySampa)) {
    String newSampa=sampa2voiceMap.get(marySampa);
    Vector<String> newSampas=new Vector<String>();
    StringTokenizer st=new StringTokenizer(newSampa);
    while (st.hasMoreTokens()) {
      newSampas.add(st.nextToken());
    }
    int n=newSampas.size();
    int totalDur=maryPhoneme.getDuration();
    Vector<int[]> allTargets=maryPhoneme.getTargets();
    for (int i=0; i < newSampas.size(); i++) {
      String sampa=newSampas.get(i);
      int dur=totalDur / n;
      Vector<int[]> newTargets=null;
      int maxP=100 * (i + 1) / n;
      boolean ok=true;
      while (allTargets != null && allTargets.size() > 0 && ok) {
        int[] oldTarget=allTargets.get(0);
        if (oldTarget[0] <= maxP) {
          int[] newTarget=new int[2];
          newTarget[0]=oldTarget[0] * n;
          newTarget[1]=oldTarget[1];
          if (newTargets == null)           newTargets=new Vector<int[]>();
          newTargets.add(newTarget);
          allTargets.remove(0);
        }
 else {
          ok=false;
        }
      }
      MBROLAPhoneme mp=new MBROLAPhoneme(sampa,dur,newTargets,maryPhoneme.getVoiceQuality());
      phones.add(mp);
    }
  }
 else {
    phones.add(maryPhoneme);
  }
  return phones;
}

public Vector < MBROLAPhoneme > convertSampa ( MBROLAPhoneme maryPhoneme ) { Vector < MBROLAPhoneme > phones = new Vector < MBROLAPhoneme > ( ) ; String marySampa = maryPhoneme . getSymbol ( ) ; if ( sampa2voiceMap != null && sampa2voiceMap . containsKey ( marySampa ) ) { String newSampa = sampa2voiceMap . get ( marySampa ) ; Vector < String > newSampas = new Vector < String > ( ) ; StringTokenizer st = new StringTokenizer ( newSampa ) ; while ( st . hasMoreTokens ( ) ) { newSampas . add ( st . nextToken ( ) ) ; } int n = newSampas . size ( ) ; int totalDur = maryPhoneme . getDuration ( ) ; Vector < int [ ] > allTargets = maryPhoneme . getTargets ( ) ; for ( int i = 0 ; i < newSampas . size ( ) ; i ++ ) { String sampa = newSampas . get ( i ) ; int dur = totalDur / n ; Vector < int [ ] > newTargets = null ; int maxP = 100 * ( i + 1 ) / n ; boolean ok = true ; while ( allTargets != null && allTargets . size ( ) > 0 && ok ) { int [ ] oldTarget = allTargets . get ( 0 ) ; if ( oldTarget [ 0 ] <= maxP ) { int [ ] newTarget = new int [ 2 ] ; newTarget [ 0 ] = oldTarget [ 0 ] * n ; newTarget [ 1 ] = oldTarget [ 1 ] ; if ( newTargets == null ) newTargets = new Vector < int [ ] > ( ) ; newTargets . add ( newTarget ) ; allTargets . remove ( 0 ) ; } else { ok = false ; } } MBROLAPhoneme mp = new MBROLAPhoneme ( sampa , dur , newTargets , maryPhoneme . getVoiceQuality ( ) ) ; phones . add ( mp ) ; } } else { phones . add ( maryPhoneme ) ; } return phones ; }
convert the sampa dialect used in mary into the sampa version used in this voice . allow for one - to - many translations , taking care of duration and f0 target adjustments .
