hmi.elckerlyc.speechengine
Class TTSUnit

java.lang.Object
  extended by hmi.elckerlyc.planunit.AbstractPlanUnit
      extended by hmi.elckerlyc.speechengine.AbstractSpeechUnit
          extended by hmi.elckerlyc.speechengine.TTSUnit
All Implemented Interfaces:
PlanUnit, SpeechUnit
Direct Known Subclasses:
DirectTTSUnit, WavTTSUnit

public abstract class TTSUnit
extends AbstractSpeechUnit


Field Summary
private  Class<? extends Behaviour> behaviourClass
           
protected  Collection<Bookmark> bookmarks
           
 int curVisime
           
private  double duration
           
private static org.slf4j.Logger logger
           
 int nextVisime
           
protected  TreeMap<Bookmark,TimePeg> pegs
           
 int prevVisime
           
protected  TTSBinding ttsBinding
           
 double visimeDuration
           
protected  Collection<Visime> visimes
           
 
Fields inherited from class hmi.elckerlyc.speechengine.AbstractSpeechUnit
bmlStartTime, speechText
 
Fields inherited from class hmi.elckerlyc.planunit.AbstractPlanUnit
bmlBlockPeg
 
Constructor Summary
TTSUnit(BMLBlockPeg bbPeg, String text, String id, String bmlId, TTSBinding ttsBin, Class<? extends Behaviour> behClass)
           
 
Method Summary
 List<String> getAvailableSyncs()
          Get the list of sync ids that can be used in this behavior.
 Class<? extends Behaviour> getBehaviourClass()
           
private  Bookmark getBookMark(String syncId)
           
 Collection<Bookmark> getBookmarks()
          Get the processed bookmarks in the speechtext (call setup before calling this)
 double getBookMarkTime(Bookmark b)
           
private  double getBookMarkTime(String bmid)
           
 TimePeg getBookMarkTimePeg(Bookmark b)
           
 TimePeg getBookMarkTimePeg(String bmid)
           
 double getPreferedDuration()
          0 is unknown/persistent
 double getRelativeTime(String syncId)
          Get the relative timing of this sync id Implementing classes should at least provide valid relative times for the BML sync points
 double getTime(String syncId)
          Get the global time of sync syncId of the PlanUnit, TimePeg.VALUEUNKNOWN if not known (yet)
 TimePeg getTimePeg(String syncId)
          null is not set
protected abstract  TimingInfo getTiming()
           
 Collection<Visime> getVisimes()
          Get the processed visimes in the speechtext (call setup before calling this)
 boolean hasValidTiming()
          Checks if the timing of this plan unit is 'valid' (e.g. stuff like start is earlier than end, but also planunit specific stuff like biomechanically possible timing).
abstract  void sendProgress(double playTime, double time)
          Send progress feedback for all bookmarks passed at playTime.
abstract  void setParameterValue(String paramater, float value)
          Sets a parameter value
 void setTimePeg(Bookmark bm, TimePeg sp)
           
 void setTimePeg(String syncId, TimePeg peg)
          Assigns a TimePeg to a sync in the PlanUnit
 void setup()
          Finds relative bookmark timing and prefered duration of the speech unit
protected  void setupCache()
           
 
Methods inherited from class hmi.elckerlyc.speechengine.AbstractSpeechUnit
getEndPeg, getEndTime, getStartPeg, getStartTime, sendEndProgress, sendStartProgress, setEnd, setStart
 
Methods inherited from class hmi.elckerlyc.planunit.AbstractPlanUnit
addFeedbackListener, feedback, getBMLBlockPeg, getBMLId, getId, getReplacementGroup, getState, isDone, isLurking, isPlaying, isSubUnit, play, playUnit, reset, resetUnit, setState, setSubUnit, start, startUnit, stop, stopUnit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface hmi.elckerlyc.planunit.PlanUnit
addFeedbackListener, feedback, getBMLBlockPeg, getBMLId, getId, getReplacementGroup, getState, isDone, isLurking, isPlaying, isSubUnit, play, reset, setParameterValue, setState, start, stop
 

Field Detail

ttsBinding

protected TTSBinding ttsBinding

duration

private double duration

bookmarks

protected Collection<Bookmark> bookmarks

visimes

protected Collection<Visime> visimes

prevVisime

public int prevVisime

curVisime

public int curVisime

nextVisime

public int nextVisime

visimeDuration

public double visimeDuration

behaviourClass

private final Class<? extends Behaviour> behaviourClass

pegs

protected TreeMap<Bookmark,TimePeg> pegs

logger

private static org.slf4j.Logger logger
Constructor Detail

TTSUnit

public TTSUnit(BMLBlockPeg bbPeg,
               String text,
               String id,
               String bmlId,
               TTSBinding ttsBin,
               Class<? extends Behaviour> behClass)
Method Detail

setParameterValue

public abstract void setParameterValue(String paramater,
                                       float value)
Description copied from interface: PlanUnit
Sets a parameter value


getBehaviourClass

public Class<? extends Behaviour> getBehaviourClass()

getBookMarkTimePeg

public TimePeg getBookMarkTimePeg(String bmid)

getBookMarkTime

public double getBookMarkTime(Bookmark b)

getBookMarkTimePeg

public TimePeg getBookMarkTimePeg(Bookmark b)

getBookMarkTime

private double getBookMarkTime(String bmid)

getBookMark

private Bookmark getBookMark(String syncId)

getTime

public double getTime(String syncId)
Description copied from interface: PlanUnit
Get the global time of sync syncId of the PlanUnit, TimePeg.VALUEUNKNOWN if not known (yet)

Specified by:
getTime in interface PlanUnit
Overrides:
getTime in class AbstractPlanUnit

getTimePeg

public TimePeg getTimePeg(String syncId)
Description copied from interface: PlanUnit
null is not set


setTimePeg

public void setTimePeg(String syncId,
                       TimePeg peg)
Description copied from interface: PlanUnit
Assigns a TimePeg to a sync in the PlanUnit


getRelativeTime

public double getRelativeTime(String syncId)
                       throws RelativeSyncNotFoundException
Description copied from interface: PlanUnit
Get the relative timing of this sync id Implementing classes should at least provide valid relative times for the BML sync points

Specified by:
getRelativeTime in interface PlanUnit
Overrides:
getRelativeTime in class AbstractPlanUnit
Returns:
relative time in range [0..1]
Throws:
RelativeSyncNotFoundException

getAvailableSyncs

public List<String> getAvailableSyncs()
Description copied from interface: PlanUnit
Get the list of sync ids that can be used in this behavior. The list is ordered in relative time and maintains the BML order for BML syncIds. All BML syncs should be present in this list.

Specified by:
getAvailableSyncs in interface PlanUnit
Overrides:
getAvailableSyncs in class AbstractPlanUnit

hasValidTiming

public boolean hasValidTiming()
Description copied from interface: PlanUnit
Checks if the timing of this plan unit is 'valid' (e.g. stuff like start is earlier than end, but also planunit specific stuff like biomechanically possible timing).

Returns:
true if valid

getPreferedDuration

public double getPreferedDuration()
Description copied from interface: PlanUnit
0 is unknown/persistent

Specified by:
getPreferedDuration in interface PlanUnit
Overrides:
getPreferedDuration in class AbstractPlanUnit
Returns:
Prefered duration (in seconds) of this speech unit (call setup before calling this)

getTiming

protected abstract TimingInfo getTiming()
                                 throws SpeechUnitPlanningException
Throws:
SpeechUnitPlanningException

setupCache

protected void setupCache()
                   throws SpeechUnitPlanningException
Throws:
SpeechUnitPlanningException - if cache setup failed.

setup

public void setup()
           throws SpeechUnitPlanningException
Finds relative bookmark timing and prefered duration of the speech unit

Throws:
SpeechUnitPlanningException

sendProgress

public abstract void sendProgress(double playTime,
                                  double time)
Send progress feedback for all bookmarks passed at playTime.

Parameters:
playTime - time since start of the speech unit
time - time since start of BML execution

setTimePeg

public void setTimePeg(Bookmark bm,
                       TimePeg sp)

getBookmarks

public Collection<Bookmark> getBookmarks()
Get the processed bookmarks in the speechtext (call setup before calling this)

Returns:
the bookmarks

getVisimes

public Collection<Visime> getVisimes()
Get the processed visimes in the speechtext (call setup before calling this)

Returns:
the visimes