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.clunits;
13 import com.sun.speech.freetts.Item;
14 import com.sun.speech.freetts.relp.LPCResult;
15 import com.sun.speech.freetts.UtteranceProcessor;
16 import com.sun.speech.freetts.Utterance;
17 import com.sun.speech.freetts.Relation;
18 import com.sun.speech.freetts.ProcessException;
20 import com.sun.speech.freetts.relp.SampleSet;
24 * Calculates the pitchmarks. This class is an UtteranceProcessor that
25 * calculates target pitchmarks for the given utterance and adds the
26 * <i>target_lpcres</i> relation to the utterance with the pitchmark
31 public class ClusterUnitPitchmarkGenerator implements UtteranceProcessor {
34 * Calculates the pitchmarks for the utterance and adds them as
35 * an LPCResult to the Utterance in a relation named
38 * @param utterance the utterance to process
42 * @throws ProcessException if an error occurs while processing
45 public void processUtterance(Utterance utterance) throws ProcessException {
53 SampleSet sts = (SampleSet) utterance.getObject("sts_list");
54 lpcResult = new LPCResult();
56 for (Item unit = utterance.getRelation(Relation.UNIT).getHead();
57 unit != null; unit = unit.getNext()) {
58 unitEntry = unit.getFeatures().getInt("unit_entry");
59 unitStart = unit.getFeatures().getInt("unit_start");
60 unitEnd = unit.getFeatures().getInt("unit_end");
61 uttSize += sts.getUnitSize(unitStart, unitEnd);
62 pitchmarks += unitEnd - unitStart;
63 unit.getFeatures().setInt("target_end", uttSize);
66 lpcResult.resizeFrames(pitchmarks);
71 int[] targetTimes = lpcResult.getTimes();
73 for (Item unit = utterance.getRelation(Relation.UNIT).getHead();
74 unit != null; unit = unit.getNext()) {
75 unitEntry = unit.getFeatures().getInt("unit_entry");
76 unitStart = unit.getFeatures().getInt("unit_start");
77 unitEnd = unit.getFeatures().getInt("unit_end");
78 for (int i = unitStart; i < unitEnd; i++,pitchmarks++) {
79 uttSize += sts.getSample(i).getResidualSize();
80 targetTimes[pitchmarks] = uttSize;
83 utterance.setObject("target_lpcres", lpcResult);
87 * Retrieves the name of this utteranceProcessor.
89 * @return the name of the utteranceProcessor
91 public String toString() {
92 return "ClusterUnitPitchmarkGenerator";