*/
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:
float end = segment.getFeatures().getFloat("end");
// Individual duration of segment, in milliseconds:
int dur = (int) ((end - prevEnd) * 1000);
StringBuffer targetStringBuffer = new StringBuffer();
while (target != null &&
target.getFeatures().getFloat("pos") <= end) {
float pos = target.getFeatures().getFloat("pos");
// time axis as percentage of segment duration:
int percentage = ((int) ((pos - prevEnd) * 1000)) * 100 / dur;
// f0 as an integer:
int f0 = (int) target.getFeatures().getFloat("f0");
targetStringBuffer.append(" ");
targetStringBuffer.append(percentage);
targetStringBuffer.append(" ");
targetStringBuffer.append(f0);
target = target.getNext();
}
// System.err.println(name + " " + dur + targetStringBuffer);
segment.getFeatures().setInt("mbr_dur", dur);
segment.getFeatures().setString("mbr_targets",
targetStringBuffer.toString().trim());