Examples of LPCResult


Examples of com.sun.speech.freetts.relp.LPCResult

  if (sampleInfo == null) {
      throw new IllegalStateException
    ("UnitConcatenator: SampleInfo does not exist");
  }

  LPCResult lpcResult = (LPCResult) utterance.getObject("target_lpcres");
  lpcResult.setValues(sampleInfo.getNumberOfChannels(),
          sampleInfo.getSampleRate(),
          sampleInfo.getResidualFold(),
          sampleInfo.getCoeffMin(),
          sampleInfo.getCoeffRange());

  // create the array of final residual sizes
  int[] targetTimes = lpcResult.getTimes();
  int[] residualSizes = lpcResult.getResidualSizes();

  int samplesSize = 0;
  if (lpcResult.getNumberOfFrames() > 0) {
    samplesSize = targetTimes[lpcResult.getNumberOfFrames() - 1];
  }
  lpcResult.resizeResiduals(samplesSize);
 
  for (Item unitItem = unitRelation.getHead(); unitItem != null;
       unitItem = unitItem.getNext()) {
      FeatureSet featureSet = unitItem.getFeatures();

      String unitName = featureSet.getString("name");
      targetEnd = featureSet.getInt("target_end");
      Unit unit = (Unit) featureSet.getObject("unit");
      int unitSize = unit.getSize();

      uIndex = 0;
      m = (float)unitSize/(float)(targetEnd - targetStart);
      numberFrames = lpcResult.getNumberOfFrames();
     
      // for all the pitchmarks that are required
      for (; (pmI < numberFrames) &&
         (targetTimes[pmI] <= targetEnd); pmI++) {

    Sample sample = unit.getNearestSample(uIndex);
   
    // Get LPC coefficients by copying
    lpcResult.setFrame(pmI, sample.getFrameData());

    // Get residual by copying
    residualSize = lpcResult.getFrameShift(pmI);
   
    residualSizes[pmI] = residualSize;
    byte[] residualData = sample.getResidualData();

    if (addResidualMethod == ADD_RESIDUAL_PULSE) {
        lpcResult.copyResidualsPulse
      (residualData, targetResidualPosition, residualSize);
    } else {
        lpcResult.copyResiduals
      (residualData, targetResidualPosition, residualSize);
    }
   
    targetResidualPosition += residualSize;
    uIndex += ((float) residualSize * m);
      }
      targetStart = targetEnd;
  }
  lpcResult.setNumberOfFrames(pmI);

  if (outputLPC) {
      lpcResult.dump();
  }
    }
View Full Code Here

Examples of com.sun.speech.freetts.relp.LPCResult

     *
     * @param utterance the utterance of interest
     */
    private void dumpASCII(Utterance utterance) {
  if (waveDumpFile != null) {
      LPCResult lpcResult =
    (LPCResult) utterance.getObject("target_lpcres");
      try {
    if (waveDumpFile.equals("-")) {
        lpcResult.dumpASCII();
    } else {
        lpcResult.dumpASCII(waveDumpFile);
    }
      } catch (IOException ioe) {
    LOGGER.severe("Can't dump file to " + waveDumpFile + " " + ioe);
    throw new Error(ioe);
      }
View Full Code Here

Examples of com.sun.speech.freetts.relp.LPCResult

  float lf0 = utterance.getVoice().getPitch();
 
  double time = 0;
  int pitchMarks = 0// how many pitch marks

  LPCResult lpcResult;
  IntLinkedList timesList = new IntLinkedList();
 
  // first pass to count how many pitch marks will be required
  for (Item targetItem = targetRelation.getHead();
       targetItem != null; targetItem = targetItem.getNext()) {
      FeatureSet featureSet = targetItem.getFeatures();
      pos = featureSet.getFloat("pos");
      f0 = featureSet.getFloat("f0");
        //System.err.println("Target pos="+pos+", f0="+f0);
      if (time == pos) {
            lf0 = f0;
    continue;
      }
      m = (f0-lf0)/pos;
        //System.err.println("m=("+f0+"-"+lf0+")/"+pos+"="+m);
      for (; time < pos; pitchMarks++) {
    time += 1/(lf0 + (time * m));
        //System.err.println("f("+time+")="+((lf0+(time*m))));
    // save the time value in a list
    timesList.add((int) (time * sampleInfo.getSampleRate()));
      }
        lf0 = f0;
  }
  lpcResult = new LPCResult();
  // resize the number of frames to the number of pitchmarks
  lpcResult.resizeFrames(pitchMarks);

  pitchMarks = 0;

  int[] targetTimes = lpcResult.getTimes();
 
  // second pass puts the values in
  timesList.resetIterator();
  for (; pitchMarks < targetTimes.length; pitchMarks++) {
      targetTimes[pitchMarks] = timesList.nextInt();
View Full Code Here

Examples of com.sun.speech.freetts.relp.LPCResult

     *
     * @throws ProcessException if an error occurs while processing
     *     the utterance
     */
    public void processUtterance(Utterance utterance) throws ProcessException {
  LPCResult lpcResult;
  int pitchmarks = 0;
  int uttSize = 0;
  int unitEntry;
  int unitStart;
  int unitEnd;

  SampleSet sts = (SampleSet) utterance.getObject("sts_list");
  lpcResult = new LPCResult();

  for (Item unit = utterance.getRelation(Relation.UNIT).getHead();
    unit != null; unit = unit.getNext()) {
      unitEntry = unit.getFeatures().getInt("unit_entry");
      unitStart = unit.getFeatures().getInt("unit_start");
      unitEnd = unit.getFeatures().getInt("unit_end");
      uttSize += sts.getUnitSize(unitStart, unitEnd);
      pitchmarks += unitEnd - unitStart;
      unit.getFeatures().setInt("target_end", uttSize);
  }

  lpcResult.resizeFrames(pitchmarks);

  pitchmarks = 0;
  uttSize = 0;

  int[] targetTimes = lpcResult.getTimes();

  for (Item unit = utterance.getRelation(Relation.UNIT).getHead();
    unit != null; unit = unit.getNext()) {
      unitEntry = unit.getFeatures().getInt("unit_entry");
      unitStart = unit.getFeatures().getInt("unit_start");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.