2 * Portions Copyright 2001 Sun Microsystems, Inc.
3 * Portions Copyright 1999-2001 Language Technologies Institute,
4 * Carnegie Mellon University.
5 * All Rights Reserved. Use is subject to license terms.
7 * See the file "license.terms" for information on usage and
8 * redistribution of this file, and for a DISCLAIMER OF ALL
11 package com.sun.speech.freetts.cart;
13 import com.sun.speech.freetts.Item;
14 import com.sun.speech.freetts.ProcessException;
15 import com.sun.speech.freetts.Relation;
16 import com.sun.speech.freetts.Utterance;
17 import com.sun.speech.freetts.UtteranceProcessor;
20 * Annotates the <code>Relation.SYLLABLE</code> relations of an
21 * utterance with "accent"
22 * and "endtone" features. Though not required, a typical use of
23 * this is to use the ToBI (tones and break indeces) scheme for
24 * transcribing intonation and accent in English, developed by Janet
25 * Pierrehumbert and Mary Beckman. This implementation is independent
26 * of the ToBI scheme: ToBI annotations are not
27 * used by this class, but are merely copied from the CART result
28 * to the "accent" and "endtone" features of the
29 * <code>Relation.SYLLABLE</code> relation.
31 public class Intonator implements UtteranceProcessor {
34 * The accent CART used for this Intonation UtteranceProcessor. It is
35 * passed into the constructor.
37 protected CART accentCart;
40 * The tone CART used for this Intonation UtteranceProcessor. It is
41 * passed into the constructor.
43 protected CART toneCart;
46 * Creates a new Intonation UtteranceProcessor with the given
49 * @param accentCart the CART for doing accents
50 * @param toneCart the CART for doing end tones
52 public Intonator(CART accentCart, CART toneCart) {
53 this.accentCart = accentCart;
54 this.toneCart = toneCart;
58 * Annotates the <code>Relation.SYLLABLE</code> relations of an
59 * utterance with "accent"
60 * and "endtone" features. Depends upon "NONE" being returned by
61 * either the accent or tone CART to indicate there isn't an
62 * intonation feature for a syllable.
64 * @param utterance the utterance to process/tokenize
66 * @throws ProcessException if an IOException is thrown during the
67 * processing of the utterance
69 public void processUtterance(Utterance utterance) throws ProcessException {
72 utterance.getRelation(Relation.SYLLABLE).getHead();
74 syllable = syllable.getNext()) {
75 results = (String) accentCart.interpret(syllable);
76 if (!results.equals("NONE")) {
77 syllable.getFeatures().setString("accent", results);
79 results = (String) toneCart.interpret(syllable);
80 if (!results.equals("NONE")) {
81 syllable.getFeatures().setString("endtone", results);
86 // inherited from Object
87 public String toString() {
88 return "CARTIntonator";