Package com.sun.speech.freetts

Examples of com.sun.speech.freetts.Item


     * @param target the target of interest
     * @param pos the time
     * @param f0 the frequency
     */
    private void addTargetPoint(Relation target, float pos, float f0) {
  Item item = target.appendItem();
  item.getFeatures().setFloat("pos", pos);
  if (f0 > 500.0) {
      item.getFeatures().setFloat("f0", 500.0f);
  } else if (f0 < 50.0)  {
      item.getFeatures().setFloat("f0", 50.0f);
  } else {
      item.getFeatures().setFloat("f0", f0);
  }
    }
View Full Code Here


     */
    public void processUtterance(Utterance utterance) throws ProcessException {
  String silence = utterance.getVoice().getFeatures().
        getString(Voice.FEATURE_SILENCE);

  Item phraseHead = utterance.getRelation(Relation.PHRASE).getHead();

  // If there are not any phrases at all, then just skip
  // the whole thing.

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

  for (Item phrase = phraseHead;
        phrase != null;
        phrase = phrase.getNext()) {
      Item word = phrase.getLastDaughter();
      while (word != null) {
    Item seg = segmentPath.findItem(word);
      // was this an explicit change or a lost bug fix
      //if (seg != null && !"".equals(puncPath.findFeature(word))) {
    if (seg != null) {
        Item pause = seg.appendItem(null);
        pause.getFeatures().setString("name", silence);
        break;
    }
    word = word.getPrevious();
      }
  }
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);
           
            if (LOGGER.isLoggable(Level.FINER)) {
                LOGGER.finer("word: " + w + ", results: " + results);
            }
View Full Code Here

    // 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

   *
   * @throws ProcessException if an exception occurred during the
   * processing
   */
  public String process(Item seg) throws ProcessException {
      Item s = seg.getItemAs(Relation.SYLLABLE_STRUCTURE);
            if (s == null) {
                return "coda";
            }

            s = s.getNext();
      while (s != null) {
    if ("+".equals(getPhoneFeature(s, "vc"))) {
        return "onset";
    }

    s = s.getNext();
      }
           
      return "coda";
  }
View Full Code Here

   * @throws ProcessException if an exception occurred during the
   * processing
   */
  public String process(Item item) throws ProcessException {
      int count = 0;
      Item inPhrase  = SUB_PHRASE_PATH.findItem(item);

      for (Item p = inPhrase; p != null; p = p.getPrevious() )  {
    count++;
      }
      return Integer.toString(rail(count));
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

     * Adds a word as an Item to this WordRelation object.
     *
     * @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

     * Sets the last Item in this WordRelation to the given word.
     *
     * @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

     *
     * @throws ProcessException if an exception occurred during the
     * processing
     */
    public static String wordBreak(Item item) throws ProcessException {
  Item ww = item.getItemAs(Relation.PHRASE);
  if (ww == null || ww.getNext() != null) {
      return "1";
  } else {
      String pname = ww.getParent().toString();
      if (pname.equals("BB")) {
    return "4";
      } else if (pname.equals("B")) {
    return "3";
      } else {
View Full Code Here

TOP

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

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.