Package com.sun.speech.freetts

Examples of com.sun.speech.freetts.Relation


     *
     * @throws ProcessException if an error occurs while
     *         processing of the utterance
     */
    public void processUtterance(Utterance utterance) throws ProcessException {
  Relation segmentRelation = utterance.getRelation(Relation.SEGMENT);
        Relation targetRelation = utterance.getRelation(Relation.TARGET);

        Item segment = segmentRelation.getHead();
        Item target = null;
  if (targetRelation != null) target = targetRelation.getHead();
        float prevEnd = 0f;
        while (segment != null) {
            // String name = segment.getFeatures().getString("name");
            // Accumulated duration of all segments in the utterance,
            // in seconds:
View Full Code Here


     * @throws ProcessException if an error occurs while
     *         processing of the utterance
     */
    public void processUtterance(Utterance utterance) throws ProcessException {
        // Go through Segment relation and print values into Mbrola
  Relation segmentRelation = utterance.getRelation(Relation.SEGMENT);
        Item segment = segmentRelation.getHead();

  if (segment == null) {
      return;
  }

View Full Code Here

 
  Item unitItem0, unitItem1;
   
  String diphoneName;
     
  Relation unitRelation = utterance.createRelation(Relation.UNIT);
  Relation segmentRelation = utterance.getRelation(Relation.SEGMENT);

  for (segmentItem0 = segmentRelation.getHead();
    segmentItem0 != null && segmentItem0.getNext() != null;
    segmentItem0 = segmentItem1) {
      segmentItem1 = segmentItem0.getNext();
      diphoneName = segmentItem0.getFeatures().getString("name") + "-" +
    segmentItem1.getFeatures().getString("name");
View Full Code Here

     */
    public void processUtterance(Utterance utterance) throws ProcessException {
  float uIndex = 0, m;
  int pmI = 0, targetResidualPosition = 0, nearestPM,
      unitPart, targetStart = 0, targetEnd, residualSize, numberFrames;
  Relation unitRelation = utterance.getRelation(Relation.UNIT);

  SampleInfo sampleInfo;
 

  int addResidualMethod = ADD_RESIDUAL;
 
  String residualType = utterance.getString("residual_type");
  if (residualType != null) {
      if (residualType.equals("pulse")) {
    addResidualMethod = ADD_RESIDUAL_PULSE;
      } else if (residualType.equals("windowed")) {
    addResidualMethod = ADD_RESIDUAL_WINDOWED;
      }
  }

  sampleInfo = (SampleInfo) utterance.getObject(SampleInfo.UTT_NAME);
  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");
View Full Code Here

     *     SampleInfo.UTT_NAME
     */
    public void processUtterance(Utterance utterance) throws ProcessException {

  // precondition that must be satisfied
  Relation targetRelation = utterance.getRelation(Relation.TARGET);
  if (targetRelation == null) {
      throw new IllegalStateException
    ("DiphonePitchmarkGenerator: Target relation does not exist");
  }

  SampleInfo sampleInfo;
  sampleInfo = (SampleInfo) utterance.getObject(SampleInfo.UTT_NAME);
  if (sampleInfo == null) {
      throw new IllegalStateException
    ("DiphonePitchmarkGenerator: SampleInfo does not exist");
  }
 
  float pos, f0, m = 0;
  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);
View Full Code Here

  mean = utterance.getVoice().getPitch();
  mean *= utterance.getVoice().getPitchShift();
  stddev = utterance.getVoice().getPitchRange();

  Relation target = utterance.createRelation(Relation.TARGET);
  for (Item syllable =
                 utterance.getRelation(Relation.SYLLABLE).getHead();
    syllable != null;
    syllable = syllable.getNext()) {

     if (syllable.getItemAs(Relation.SYLLABLE_STRUCTURE).hasDaughters()) {

          tval = localF0Shift.findFeature(syllable);
    localMean  = Float.parseFloat(tval.toString());

    if (localMean == 0.0) {
        localMean = mean;
    } else {
        localMean *= mean;
    }

          tval = localF0Range.findFeature(syllable);
    localStddev  = Float.parseFloat(tval.toString());

    if (localStddev == 0.0) {
        localStddev = stddev;
    }

          Interceptor interceptor = applyLrModel(syllable);
    if (isPostBreak(syllable)) {
        lend = mapF0(interceptor.start, localMean, localStddev);
    }

    Float val = (Float) endPath.findFeature(syllable);
    // assert val != null;
    // don't mind null ptr exception
    addTargetPoint(target, val.floatValue(),
      mapF0((interceptor.start + lend) / 2.0f,
          localMean, localStddev));
    addTargetPoint(target, vowelMid(syllable),
      mapF0(interceptor.mid, localMean, localStddev));
    lend = mapF0(interceptor.end, localMean, localStddev);
    if (isPreBreak(syllable)) {
        Float eval = (Float) lastDaughterEndPath.findFeature(
          syllable);
        addTargetPoint(target, eval.floatValue(),
          mapF0(interceptor.end, localMean, localStddev));
    }
      }
  }

  if (utterance.getRelation(Relation.SEGMENT).getHead() != null) {
      Item first = target.getHead();
      if (first == null) {
    addTargetPoint(target, 0, mean);
      } else  if (first.getFeatures().getFloat("pos") > 0) {
        Item newItem = first.prependItem(null);
        newItem.getFeatures().setFloat("pos", 0.0f);
        newItem.getFeatures().setFloat(
          "f0", first.getFeatures().getFloat("f0"));
      }
      Item last = (Item) target.getTail();
      Item lastSegment
    = utterance.getRelation(Relation.SEGMENT).getTail();
      float segEnd = 0.0f;

      if (lastSegment != null) {
View Full Code Here

  if (phraseHead == null) {
      return;
  }

  // insert initial silence
  Relation segment = utterance.getRelation(Relation.SEGMENT);
  Item s = segment.getHead();
  if (s == null) {
      s = segment.appendItem(null);
  } else {
     s = s.prependItem(null);
  }
  s.getFeatures().setString("name", silence);
View Full Code Here

     *
     * @throws ProcessException if a problem is encountered during the
     *         processing of the utterance
     */
    public void processUtterance(Utterance utterance) throws ProcessException {
        Relation relation = utterance.createRelation(Relation.PHRASE);
        Item p = null;
        for (Item w = utterance.getRelation(Relation.WORD).getHead();
      w != null; w = w.getNext()) {
            if (p == null) {
                p = relation.appendItem();
                p.getFeatures().setString("name","BB");
            }
            p.addDaughter(w);
            String results = (String) cart.interpret(w);
           
View Full Code Here

     *         processing of the utterance
     *
     */
    public void processUtterance(Utterance utterance) throws ProcessException {
  Viterbi vd;
  Relation segs = utterance.getRelation(Relation.SEGMENT);

  utterance.setObject(SampleInfo.UTT_NAME,
    clunitDB.getSampleInfo());
      utterance.setObject("sts_list", clunitDB.getSts());

  vd = new Viterbi(segs, clunitDB);
 
  for (Item s = segs.getHead(); s != null; s = s.getNext()) {
      setUnitName(s);
  }

    // Carry out the CART lookup for the target costs, and the viterbi
    // search for finding the best path (join costs) through the candidates.
  vd.decode();

    // Now associate the candidate units in the best path
    // with the items in the segment relation.
  if (!vd.result("selected_unit")) {
      LOGGER.severe("clunits: can't find path");
      throw new Error();
  }

    // If optimal coupling was used, the join points must now be copied
    // from the path elements to the actual items in the segment relation.
  vd.copyFeature("unit_prev_move");
  vd.copyFeature("unit_this_move");

    // Based on this data, create a Unit relation giving the details of the
    // units to concatenate.
  Relation unitRelation = utterance.createRelation(Relation.UNIT);

  for (Item s = segs.getHead(); s != null; s = s.getNext()) {
      Item unit = unitRelation.appendItem();
      FeatureSet unitFeatureSet = unit.getFeatures();
      int unitEntry = s.getFeatures().getInt("selected_unit");

        // The item name is the segment name
      unitFeatureSet.setString("name", s.getFeatures().getString("name"));
View Full Code Here

     *
     * @return a WordRelation object
     */
    public static WordRelation createWordRelation(Utterance utterance,
              TokenToWords tokenToWords) {
  Relation relation = utterance.createRelation(Relation.WORD);
  return new WordRelation(relation, tokenToWords);
    }
View Full Code Here

TOP

Related Classes of com.sun.speech.freetts.Relation

Copyright © 2018 www.massapicom. 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.