Package edu.tufts.hrilab.tts
Class StreamingTTSComponent
java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.tts.StreamingTTSComponent
- All Implemented Interfaces:
SpeechProductionInterface
Streaming TTS behind a pluggable synthesis backend (kokoro by default). The LLM streaming
path pushes phrase fragments via pushStreamingSpeech/endStreamingSpeech; the backend turns
one phrase into PCM and nothing else.
-
Field Summary
Fields inherited from class edu.tufts.hrilab.diarc.DiarcComponent
executionLoopCycleTime, log, shouldRunExecutionLoop -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected List<org.apache.commons.cli.Option>Override this method to define command line options available in sub-class.voidvoidcancelStreamingTTSOutputForUID(long uid) booleanendStreamingSpeech(boolean wait) booleanendStreamingSpeech(boolean wait, long uid) intprotected voidinit()Perform any component initialization.booleanChecks if speech is being produced.booleanisStreamingSpeech(long uid) booleanprotected voidparseArgs(org.apache.commons.cli.CommandLine cmdLine) Override this method to parse command line args in the sub-class.voidplayAudioClip(String path) voidpushStreamingSpeech(String fragment) voidpushStreamingSpeech(String fragment, long uid) booleanbooleanSpeaks appropriate text, blocking.booleanSpeaks appropriate textbooleansetVoiceVolume(int percent) booleansetVoiceVolume(Symbol volumeSymbol) protected voidAny component that needs particular shutdown logic needs to override this method andbooleanStops an ongoing utterance.voidvoidvoidunbufferStreamingTTSOutputForUID(long uid) voidwaitForStreamingSpeechCompletion(long uid) Methods inherited from class edu.tufts.hrilab.diarc.DiarcComponent
attachShutdownHook, createInstance, createInstance, createInstance, executionLoop, getMyGroupConstraints, getMyGroups, getMyService, getMyServices, main, postRegistrationInit, shutdown
-
Constructor Details
-
StreamingTTSComponent
public StreamingTTSComponent()
-
-
Method Details
-
additionalUsageInfo
Description copied from class:DiarcComponentOverride this method to define command line options available in sub-class. This should be paired with a parseArgs implementation.- Overrides:
additionalUsageInfoin classDiarcComponent- Returns:
-
parseArgs
protected void parseArgs(org.apache.commons.cli.CommandLine cmdLine) Description copied from class:DiarcComponentOverride this method to parse command line args in the sub-class. Called directly after construction to pass runtime values that will override default values. This should parse all the options that additionalUsageInfo provides.- Overrides:
parseArgsin classDiarcComponent
-
init
protected void init()Description copied from class:DiarcComponentPerform any component initialization. This should not be used for setting local fields to default values as was the case in DIARC. This method is called after the constructor, and after parseArgs. Setting default values should be done in field declaration or in the constructor.- Overrides:
initin classDiarcComponent
-
shutdownComponent
protected void shutdownComponent()Description copied from class:DiarcComponentAny component that needs particular shutdown logic needs to override this method and- Overrides:
shutdownComponentin classDiarcComponent
-
sayText
Description copied from interface:SpeechProductionInterfaceSpeaks appropriate text, blocking.- Specified by:
sayTextin interfaceSpeechProductionInterface- Parameters:
text- the text to be spoken
-
sayText
Description copied from interface:SpeechProductionInterfaceSpeaks appropriate text- Specified by:
sayTextin interfaceSpeechProductionInterface- Parameters:
text- the text to be spokenwait- whether or not to block until speaking call returns
-
pushStreamingSpeech
-
pushStreamingSpeech
-
unbufferStreamingTTSOutputForUID
public void unbufferStreamingTTSOutputForUID(long uid) -
cancelStreamingTTSOutputForUID
public void cancelStreamingTTSOutputForUID(long uid) -
endStreamingSpeech
public boolean endStreamingSpeech(boolean wait) -
endStreamingSpeech
public boolean endStreamingSpeech(boolean wait, long uid) -
waitForStreamingSpeechCompletion
public void waitForStreamingSpeechCompletion(long uid) -
isStreamingSpeech
public boolean isStreamingSpeech(long uid) -
isSpeaking
public boolean isSpeaking()Description copied from interface:SpeechProductionInterfaceChecks if speech is being produced.- Specified by:
isSpeakingin interfaceSpeechProductionInterface- Returns:
trueif speech is being produced,falseotherwise
-
stopUtterance
public boolean stopUtterance()Description copied from interface:SpeechProductionInterfaceStops an ongoing utterance.- Specified by:
stopUtterancein interfaceSpeechProductionInterface- Returns:
- true if speech is interrupted, false otherwise.
-
armPostStreamRearm
public void armPostStreamRearm() -
playAudioClip
-
toggleVoiceOn
public void toggleVoiceOn() -
toggleVoiceOff
public void toggleVoiceOff() -
setVoiceVolume
-
setVoiceVolume
public boolean setVoiceVolume(int percent) -
lowerVoiceVolume
public boolean lowerVoiceVolume() -
raiseVoiceVolume
public boolean raiseVoiceVolume() -
getVoiceVolume
public int getVoiceVolume()
-