Package speakeasy :: Module robot_interaction :: Class RoboComm
[hide private]
[frames] | no frames]

Class RoboComm

source code

object --+
         |
        RoboComm

Provides all methods required to operate the SpeakEasy ROS node remotely. Intention is for GUIs or other programs to use one instance of this class to control all text-to-speech, sound effects, and music play functions if those functions are provided by a SpeakEasy ROS node. <p> For an exmple to use if these three functions are provided locally, without using ROS, see speakeasy_controller.py.

Nested Classes [hide private]
  ReplayDemon
Abstract class of all repeat demons: text-to-speech, sound effects, and music.
  SoundReplayDemon
Responsible for repeating sound effects at appropriate intervals.
  MusicReplayDemon
Responsible for repeating songs at appropriate intervals.
  SpeechReplayDemon
Responsible for repeating text-to-speech utterances at appropriate intervals.
Instance Methods [hide private]
 
__init__(self)
Initialize sound to play at the robot.
source code
bool
robotAvailable(self)
Return True if a SpeakEasy service is available, i.e.
source code
SpeakEasyStatus
getSpeakEasyNodeStatus(self, cachedOK=False)
Return a SpeakEasy status message instance as received from a live SpeakEasy node.
source code
[string]
getSoundEffectNames(self, cachedOK=False)
Return a list of the sound effects that the SpeakEasy node is offering.
source code
[bool]
getSongNames(self, cachedOK=False)
Return a list of the music files that the SpeakEasy node is offering.
source code
[string]
getTextToSpeechEngineNames(self, cachedOK=False)
Return array of text-to-speech engines that are available at the SpeakEasy node.
source code
[string]
getVoiceNames(self, ttsEngine=None, cachedOK=False)
Return a list of text-to-speech voices that the SpeakEasy node provides.
source code
int
getNumSoundChannels(self, cachedOK=False)
Return the number of simultaneous sound effects that the SpeakEasy node provides.
source code
float
getSoundVolume(self, cachedOK=False)
Return default sound effect volume level.
source code
float
getMusicVolume(self, cachedOK=False)
Return default music volume level.
source code
PlayStatus
getPlayStatus(self, cachedOK=False)
Return current music play state.
source code
bool
getMusicBusy(self)
Convenience method to determine whether music is currently either playing or paused.
source code
bool
getTextToSpeechBusy(self, cachedOK=False)
Return whether SpeakEasy node is currently generating speech from text.
source code
 
say(self, text, voice=None, ttsEngine=None, numRepeats=0, repeatPeriod=0, blockTillDone=False)
Given a piece of text, generate corresponding speech at the SpeakEasy node site.
source code
 
stopSaying(self)
Stop text-to-speech utterance.
source code
 
playSound(self, soundName, volume=None, numRepeats=0, repeatPeriod=0)
Play a sound effect at the SpeakEasy node.
source code
 
stopSound(self)
Stop the all currently playing sound effects.
source code
 
pauseSound(self)
Pause the all currently playing sound effects.
source code
 
unPauseSound(self)
Un-pause all currently paused sound effects.
source code
 
setSoundVolume(self, volume, soundName=None)
Change the sound effect default volume.
source code
 
playMusic(self, songName, volume=None, playheadTime=0.0, timeReference=1, numRepeats=0, repeatPeriod=0)
Play a piece of music (a sound file) at the SpeakEasy node.
source code
 
stopMusic(self)
Stop currently playing music.
source code
 
pauseMusic(self)
Pause currently playing music.
source code
 
unPauseMusic(self)
Un-pause currently playing music.
source code
 
setMusicVolume(self, vol)
Set default volume of music playback.
source code
 
setPlayhead(self, playheadTime, timeReference=1)
Change the music playhead position to a particular time within a song.
source code
float
getPlayhead(self)
Return song position in fractional seconds.
source code
 
registerSpeechRepeaterThread(self, speechThread) source code
 
killSpeechRepeatThreads(self, speechThreads) source code
 
registerSoundRepeaterThread(self, soundThread) source code
 
killSoundRepeatThreads(self, soundThreads) source code
 
registerMusicRepeaterThread(self, musicThread) source code
 
killMusicRepeatThreads(self, musicThreads) source code
 
unregisterRepeatThread(self, threadObj, threadList) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  STATUS_MSG_TIMEOUT = 5
  PLAYHEAD_MSG_TIMEOUT = 0.5
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

Initialize sound to play at the robot. Initializes self.sound_file_names to a list of sound file names for use with play-sound calls to the Robot via ROS.

Raises:
  • NotImplementedError - if ROS initialization failed.
  • IOError - if SpeakEasy node is online, but service call to it failed.
Overrides: object.__init__

robotAvailable(self)

source code 

Return True if a SpeakEasy service is available, i.e. if a SpeakEasy ROS node is running. Else return False.

Returns: bool
Result of checking whether a live SpeakEasy node is detected.

getSpeakEasyNodeStatus(self, cachedOK=False)

source code 

Return a SpeakEasy status message instance as received from a live SpeakEasy node. See msg.SpeakEasyStatus.msg for field details.

Parameters:
  • cachedOK (bool) - Set True if OK to use a previously cached status message.
Returns: SpeakEasyStatus
Message instance if available, else None. Message instances are unavailable if no SpeakEasy node is running.

getSoundEffectNames(self, cachedOK=False)

source code 

Return a list of the sound effects that the SpeakEasy node is offering. These effects may be invoked via the playSound() method.

Parameters:
  • cachedOK (bool) - Set True if OK to use a previously cached status message.
Returns: [string]
Array of sound effect names.

getSongNames(self, cachedOK=False)

source code 

Return a list of the music files that the SpeakEasy node is offering. These songs may be played via the playMusic() method.

Parameters:
  • cachedOK (bool) - Set True if OK to use a previously cached status message.
Returns: [bool]
Array of music files.

getTextToSpeechEngineNames(self, cachedOK=False)

source code 

Return array of text-to-speech engines that are available at the SpeakEasy node. Examples: Festival, the Linux open source engine, or Cepstral, the commercial engine.

Parameters:
  • cachedOK (bool) - Set True if OK to use a previously cached status message.
Returns: [string]
List of engine names.

getVoiceNames(self, ttsEngine=None, cachedOK=False)

source code 

Return a list of text-to-speech voices that the SpeakEasy node provides. If a particular text-to-speech engine is specified, only that engine's voices are returned, else all voices of all available engines are returned in one list.

Parameters:
  • ttsEngine (string) - Name of one available text-to-speech engine.
  • cachedOK (bool) - Set True if OK to use a previously cached status message.
Returns: [string]
List of voice names, or empty list. List may be empty either because the SpeakEasy node does not offer text-to-speech services, or because the node has terminated, and is no longer broadcasting status messages.

getNumSoundChannels(self, cachedOK=False)

source code 

Return the number of simultaneous sound effects that the SpeakEasy node provides. Note that SpeakEasy nodes can be configured to provide many sound effect channels, though this API does not provide such control. Default is eight.

Parameters:
  • cachedOK (bool) - Set True if OK to use a previously cached status message.
Returns: int
Number of sound effect channels.

getSoundVolume(self, cachedOK=False)

source code 

Return default sound effect volume level. Note that sound volume can be set on a case-by-case basis in calls to playSound();

Parameters:
  • cachedOK (bool) - Set True if OK to use a previously cached status message.
Returns: float
Default sound volume as a number between 0.0 and 1.0.

getMusicVolume(self, cachedOK=False)

source code 

Return default music volume level. Note that music volume can be set on a case-by-case basis in calls to playMusic();

Parameters:
  • cachedOK (bool) - Set True if OK to use a previously cached status message.
Returns: float
Default sound volume as a number between 0.0 and 1.0.

getPlayStatus(self, cachedOK=False)

source code 

Return current music play state. These states are defined in music_player.py. For reference, at the time of this writing: class PlayStatus:

  • STOPPED = 0;
  • PAUSED = 1;
  • PLAYING = 2;
Parameters:
  • cachedOK (bool) - Set True if OK to use a previously cached status message.
Returns: PlayStatus
Status of the music playback engine on the SpeakEasy node.

getMusicBusy(self)

source code 

Convenience method to determine whether music is currently either playing or paused.

Returns: bool
True/False to indicate whether music status is currently PlayStatus.STOPPED.

getTextToSpeechBusy(self, cachedOK=False)

source code 

Return whether SpeakEasy node is currently generating speech from text.

Returns: bool
True/False to indicate whether text-to-speech engine is busy.

say(self, text, voice=None, ttsEngine=None, numRepeats=0, repeatPeriod=0, blockTillDone=False)

source code 

Given a piece of text, generate corresponding speech at the SpeakEasy node site.

Parameters:
  • text (string) - Words to speak.
  • voice (string) - Name of text-to-speech voice to use.
  • ttsEngine (string) - Name of text-to-speech engine to use.
  • numRepeats (int) - Number of times the utterance is to be repeated after the first time. Use -1 if forever.
  • repeatPeriod (float) - Time period in fractional seconds to wait between repeated utterances.
  • blockTillDone (bool) - Request to return immediately, or block until the utterance if finished.
Raises:
  • TypeError - if one of the parameters is of incorrect type.

stopSaying(self)

source code 

Stop text-to-speech utterance. No effect if text-to-speech is currently inactive.

playSound(self, soundName, volume=None, numRepeats=0, repeatPeriod=0)

source code 

Play a sound effect at the SpeakEasy node.

Parameters:
  • soundName (string) - Name of the sound effect. (see getSoundEffectNames()).
  • volume (float.) - Loudness for the sound effect. If None, current volume is used. Volume must be in range 0.0 to 1.0
  • numRepeats (int) - Number of times the sound effect is to be repeated after the first time. Use -1 to play forever.
  • repeatPeriod (float) - Time period in fractional seconds to wait between repeats.
Raises:
  • TypeError - if any parameter is of the wrong type.

stopSound(self)

source code 

Stop the all currently playing sound effects. Method has no effect if no sound is currently playing.

pauseSound(self)

source code 

Pause the all currently playing sound effects. Method has no effect if no sound is currently playing.

unPauseSound(self)

source code 

Un-pause all currently paused sound effects. Method has no effect if no sound is currently paused.

setSoundVolume(self, volume, soundName=None)

source code 

Change the sound effect default volume.

Parameters:
  • volume (float) - New default volume for sound effects. Value must be in range 0.0 to 1.0.
  • soundName (string) - Optionally the name of the sound whose volume is to be changed.
Raises:
  • TypeError - if any parameters are of incorrect type.

playMusic(self, songName, volume=None, playheadTime=0.0, timeReference=1, numRepeats=0, repeatPeriod=0)

source code 

Play a piece of music (a sound file) at the SpeakEasy node.

Parameters:
  • songName (string) - Name of sound file. (See getSongNames()).
  • volume ({None | float}) - Loudness at which to play. Default uses current volume. Else must be in range 0.0 to 1.0
  • playheadTime (float) - Offset in fractional seconds into where to start the song. Default: start at beginning.
  • timeReference (TimeReference) - If playheadTime is provided, specifies whether the given time is intended as absolute (relative to the beginning of the song), or relative to the current playhead position.
  • numRepeats (int) - Number of times the song is to be repeated after the first time. Use -1 to play forever.
  • repeatPeriod (float) - Time period in fractional seconds to wait between repeats.
Raises:
  • TypeError - if any parameters are of incorrect type.

stopMusic(self)

source code 

Stop currently playing music. No effect if nothing playing.

pauseMusic(self)

source code 

Pause currently playing music. No effect if nothing playing.

unPauseMusic(self)

source code 

Un-pause currently playing music. No effect if nothing paused or playing.

setMusicVolume(self, vol)

source code 

Set default volume of music playback.

Parameters:
  • vol (float) - Loudness value between 0.0 and 1.0.
Raises:
  • TypeError - if any parameters are of incorrect type.

setPlayhead(self, playheadTime, timeReference=1)

source code 

Change the music playhead position to a particular time within a song. Time may be specified absolute (i.e. relative to the start of the song), or relative to the current playhead. The playhead may be changed during playback, or while a song is paused.

Parameters:
  • playheadTime (float) - New time where to position the playhead.
  • timeReference (TimeReference.) - TimeReference.ABSOLUTE or TimeReference.RELATIVE
Raises:
  • TypeError - if any parameters are of incorrect type.

getPlayhead(self)

source code 

Return song position in fractional seconds. Return None if no music is currently playing.

Returns: float
Position in fractional seconds.