Package com.sun.speech.freetts

Examples of com.sun.speech.freetts.FeatureSet


      System.err.println
    ("FreeTTS: unit database failed to find entry for: " +
     diphoneName);
  }
  Item unit = unitRelation.appendItem();
  FeatureSet unitFeatureSet = unit.getFeatures();

  unitFeatureSet.setString("name", diphoneName);
  unitFeatureSet.setInt("target_end", targetEnd);
  unitFeatureSet.setObject("unit", new DiphoneUnit(diphone, unitPart));
  // unitFeatureSet.setInt("unit_part", unitPart);
  return unit;
    }
View Full Code Here


  }
  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();
View Full Code Here

     * @param segment the Segment Item
     *
     * @return the <code>end</code> feature of the Segment
     */
    public static float getSegmentEnd(Item segment) {
  FeatureSet segmentFeatureSet = segment.getFeatures();
  return segmentFeatureSet.getFloat("end");
    }
View Full Code Here

  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;
      }
View Full Code Here

    // 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"));

      int unitStart;
      int unitEnd;
      String clunitName = s.getFeatures().getString("clunit_name");

      if (s.getFeatures().isPresent("unit_this_move")) {
    unitStart = s.getFeatures().getInt("unit_this_move");
      } else {
    unitStart = clunitDB.getStart(unitEntry);
      }

      if (s.getNext() != null &&
        s.getNext().getFeatures().isPresent("unit_prev_move")) {
    unitEnd = s.getNext().getFeatures().getInt("unit_prev_move");
      } else {
    unitEnd = clunitDB.getEnd(unitEntry);
      }

      unitFeatureSet.setInt("unit_entry", unitEntry);
      ClusterUnit clunit = new ClusterUnit(clunitDB,
        clunitName, unitStart, unitEnd);
      unitFeatureSet.setObject("unit", clunit);
      if (true) {
    unitFeatureSet.setInt("unit_start", clunit.getStart());
    unitFeatureSet.setInt("unit_end", clunit.getEnd());
        unitFeatureSet.setInt("instance", unitEntry - clunitDB.getUnitIndex(clunitName, 0));
      } // add the rest of these things for debugging.

      if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.fine(" sr " + clunitDB.getSampleInfo().getSampleRate() + " " +
        s.getFeatures().getFloat("end") + " " +
        (int) (s.getFeatures().getFloat("end") *
         clunitDB.getSampleInfo().getSampleRate()));
      }
      unitFeatureSet.setInt("target_end",
    (int) (s.getFeatures().getFloat("end")
           * clunitDB.getSampleInfo().getSampleRate()));
 
      // Associate debug info about unit origin if available:
        UnitOriginInfo unitOrigin = clunitDB.getUnitOriginInfo(unitEntry);
      if (unitOrigin != null) {
          unitFeatureSet.setString("origin", unitOrigin.originFile);
          unitFeatureSet.setFloat("origin_start", unitOrigin.originStart);
            unitFeatureSet.setFloat("origin_end", unitOrigin.originEnd);
        }
       
  }
    }
View Full Code Here

     * Adds a break as a feature to the last item in the list.
     */
    public void addBreak() {
  Item wordItem = (Item) relation.getTail();
  if (wordItem != null) {
      FeatureSet featureSet = wordItem.getFeatures();
      featureSet.setString("break", "1");
  }
    }
View Full Code Here

     * @param word the word to add
     */
    public void addWord(String word) {
  Item tokenItem = tokenToWords.getTokenItem();
  Item wordItem = tokenItem.createDaughter();
  FeatureSet featureSet = wordItem.getFeatures();
  featureSet.setString("name", word);
  relation.appendItem(wordItem);
    }
View Full Code Here

     *
     * @param word the word to set
     */
    public void setLastWord(String word) {
  Item lastItem = relation.getTail();
  FeatureSet featureSet = lastItem.getFeatures();
  featureSet.setString("name", word);
    }
View Full Code Here

 
  for (tokenItem = tokenRelation.getHead();
       tokenItem != null;
       tokenItem = tokenItem.getNext()) {

      FeatureSet featureSet = tokenItem.getFeatures();
      String tokenVal = featureSet.getString("name");
     
      // convert the token into a list of words
      tokenToWords(tokenVal);
  }
    }
View Full Code Here

     *                  same as the one in called "name" in flite
     *
     */
    private void tokenToWords(String tokenVal) {

  FeatureSet tokenFeatures = tokenItem.getFeatures();
  String itemName = tokenFeatures.getString("name");
  int tokenLength = tokenVal.length();

  if (tokenFeatures.isPresent("phones")) {
      wordRelation.addWord(tokenVal);

  } else if ((tokenVal.equals("a") || tokenVal.equals("A")) &&
                ((tokenItem.getNext() == null) ||
                 !(tokenVal.equals(itemName)) ||
                 !(((String) tokenItem.findFeature("punc")).equals("")))) {
      /* if A is a sub part of a token, then its ey not ah */
      wordRelation.addWord("_a");

  } else if (matches(alphabetPattern, tokenVal)) {

      if (matches(romanNumbersPattern, tokenVal)) {
   
    /* XVIII */
    romanToWords(tokenVal);
   
      } else if (matches(illionPattern, tokenVal) &&
           matches(usMoneyPattern,
             (String) tokenItem.findFeature("p.name"))) {
    /* $ X -illion */
    wordRelation.addWord(tokenVal);
    wordRelation.addWord("dollars");     
   
      } else if (matches(drStPattern, tokenVal)) {
   
    /* St Andrew's St, Dr King Dr */
    drStToWords(tokenVal);
   
      } else if (tokenVal.equals("Mr")) {
   
    tokenItem.getFeatures().setString("punc", "");
    wordRelation.addWord("mister");
   
      } else if (tokenVal.equals("Mrs")) {
   
    tokenItem.getFeatures().setString("punc", "");
    wordRelation.addWord("missus");
   
      } else if (tokenLength == 1
           && isUppercaseLetter(tokenVal.charAt(0))
           && ((String)tokenItem.findFeature("n.whitespace")).equals(" ")
           && isUppercaseLetter
           (((String) tokenItem.findFeature("n.name")).charAt(0))) {
   
    tokenFeatures.setString("punc", "");
    String aaa = tokenVal.toLowerCase();
    if (aaa.equals("a")) {
        wordRelation.addWord("_a");
    } else {
        wordRelation.addWord(aaa);
    }
      } else if (isStateName(tokenVal)) {
    /*
      The name of a US state
      isStateName() has already added the full name of the
      state, so we're all set.
    */
      } else if (tokenLength > 1 && !isPronounceable(tokenVal)) {
    /* Need common exception list */
    /* unpronouncable list of alphas */
    NumberExpander.expandLetters
        (tokenVal, wordRelation);
   
      } else {
    /* just a word */
    wordRelation.addWord(tokenVal.toLowerCase());
      }
     
  } else if (matches(dottedAbbrevPattern, tokenVal)) {
     
      /* U.S.A. */
      // remove all dots
      String aaa = Utilities.deleteChar(tokenVal, '.');
      NumberExpander.expandLetters(aaa, wordRelation);
     
  } else if (matches(commaIntPattern, tokenVal)) {
     
      /* 99,999,999 */
      String aaa = Utilities.deleteChar(tokenVal, ',');
      NumberExpander.expandReal(aaa, wordRelation);
     
  } else if (matches(sevenPhoneNumberPattern, tokenVal)) {
     
      /* 234-3434  telephone numbers */
      int dashIndex = tokenVal.indexOf('-');
      String aaa = tokenVal.substring(0, dashIndex);
      String bbb = tokenVal.substring(dashIndex+1);
     
      NumberExpander.expandDigits(aaa, wordRelation);
      wordRelation.addBreak();
      NumberExpander.expandDigits(bbb, wordRelation);
     
  } else if (matchesPartPhoneNumber(tokenVal)) {
     
      /* part of a telephone number */
      String punctuation = (String) tokenItem.findFeature("punc");
      if (punctuation.equals("")) {
    tokenItem.getFeatures().setString("punc", ",");
      }
      NumberExpander.expandDigits(tokenVal, wordRelation);
      wordRelation.addBreak();
   
  } else if (matches(numberTimePattern, tokenVal)) {
     
      /* 12:35 */
      int colonIndex = tokenVal.indexOf(':');
      String aaa = tokenVal.substring(0, colonIndex);
      String bbb = tokenVal.substring(colonIndex+1);
     
      NumberExpander.expandNumber(aaa, wordRelation);
      if (!(bbb.equals("00"))) {
    NumberExpander.expandID(bbb, wordRelation);
      }
     
  } else if (matches(digits2DashPattern, tokenVal)) {
     
      /* 999-999-999 */
      digitsDashToWords(tokenVal);
     
  } else if (matches(digitsPattern, tokenVal)) {
     
      digitsToWords(tokenVal);
     
  } else if (tokenLength == 1
       && isUppercaseLetter(tokenVal.charAt(0))
       && ((String)tokenItem.findFeature("n.whitespace")).equals
                   (" ")
       && isUppercaseLetter
       (((String) tokenItem.findFeature("n.name")).charAt(0))) {
     
      tokenFeatures.setString("punc", "");
      String aaa = tokenVal.toLowerCase();
      if (aaa.equals("a")) {
    wordRelation.addWord("_a");
      } else {
    wordRelation.addWord(aaa);
View Full Code Here

TOP

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

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.