Module GSpeech :: Class GSpeech
[hide private]
[frames] | no frames]

Class GSpeech

source code

 ??-294 --+    
          |    
Audio.Audio --+
              |
             GSpeech

Defines an abstract base class to send output from SUE to a speech device via gnome-speech http://cvs.gnome.org/viewcvs/gnome-speech/. A subclass must override the DEVICE_IID class variable to indicate which gnome-speech server should be instantiated. If the specific speech server does not have named parameters that map automatically to the style properties in AEOutput.Style, createDistinctStyles and _applyStyle should be overridden. If the default style should be something other than an empty shell object to be dynamically populated in createDistinctStyles.

To be compliant with SUE requirements, this implements the interface defined in the Audio class.

Nested Classes [hide private]
  STYLE
Style object built dynamically as we discover what capabilities the active gnome-speech driver supports.
Instance Methods [hide private]
 
_applyStyle(self, style)
Applies a given style to this output device.
source code
GNOME.Speech.Speaker
createSpeaker(self, voice)
Creates a new speaker object from the given voice.
source code
list
getVoices(self)
Gets the list of available voices
source code
 
init(self)
Initializes the speech driver through gnome-speech.
source code
 
_say(self, text)
Loops until speaker.say succeeds by returning a non-negative value.
source code
 
close(self)
Stops and closes the speech device.
source code
 
sendStop(self, style=None)
Stops speech immediately.
source code
 
sendTalk(self, style=None)
Begins synthesis of the buffered text.
source code
 
sendString(self, text, style)
Adds the given string to the text to be synthesized.
source code
boolean
isActive(self)
Indicates whether the device is active meaning it is busy doing output or has text waiting to be output.
source code
integer
sendIndex(self, style)
Sends an index marker to the device driver.
source code
list of AEOutput.Style
createDistinctStyles(self, num_groups, num_layers)
Creates distinct styles following the guidelines set forth in the base class.
source code

Inherited from Audio.Audio: __init__, addIndexListener, getCapabilities, getProxy, parseString, removeIndexListener, send, sendFilename, sendGetClosestLang, sendStringSync

Inherited from Audio.Audio (private): _parseMain

Class Variables [hide private]
string DEVICE_IID = None
Interface identifier for the gnome-speech device.
Instance Variables [hide private]
list buffer
Buffer of text and styles to be sent to the device
GNOME.Speech.SynthesisDriver driver
Reference to a speech engine server
AEOutput.Style last_style
Last style object to be applied to output
GNOME.Speech.Speaker speaker
Speaker that will synthesize speech from buffered text
list voices
List of all gnome-speech voices

Inherited from Audio.Audio: listeners

Method Details [hide private]

_applyStyle(self, style)

source code 
Applies a given style to this output device. All output following this call will be presented in the given style until this method is called again with a different style.
Parameters:

createSpeaker(self, voice)

source code 
Creates a new speaker object from the given voice.
Parameters:
  • voice (GNOME.Speech.VoiceInfo) - Voice object
Returns: GNOME.Speech.Speaker
New speaker object

getVoices(self)

source code 
Gets the list of available voices
Returns: list
List of all gnome-speech voice objects

init(self)

source code 
Initializes the speech driver through gnome-speech.
Raises:
  • AEOutput.InitError - When the device can not be initialized

_say(self, text)

source code 
Loops until speaker.say succeeds by returning a non-negative value.
Parameters:
  • text (string) - Text to say

Note: gnome-speech returns a negative value when there is a backlog of events that must be processed by a GNOME.Speech.SpeechCallback before say will succeed

sendStop(self, style=None)

source code 
Stops speech immediately.
Parameters:
Overrides: Audio.Audio.sendStop

sendTalk(self, style=None)

source code 
Begins synthesis of the buffered text.
Parameters:
Overrides: Audio.Audio.sendTalk

sendString(self, text, style)

source code 
Adds the given string to the text to be synthesized. The string is buffered locally in this object since gnome-speech does not support buffering in the speech engine driver, even if the engine does support it.
Parameters:
  • text (string) - String to buffer on the device
  • style (integer) - Style with which this string should be output; None means no style change should be applied
Overrides: Audio.Audio.sendString

isActive(self)

source code 
Indicates whether the device is active meaning it is busy doing output or has text waiting to be output.
Returns: boolean
True when the speech device is synthesizing, False otherwise

sendIndex(self, style)

source code 
Sends an index marker to the device driver. The driver should notify the device when the marker has been reached during output.
Parameters:
  • style (AEOutput.Style) - Style indicating channel in which the marker will be appended
Returns: integer
Unique marker identifying the index inserted
Overrides: Audio.Audio.sendIndex

To Do: PP: implement when index working

createDistinctStyles(self, num_groups, num_layers)

source code 
Creates distinct styles following the guidelines set forth in the base class. Only distinguishes groups in terms of voice, not layers. Assumes rate, pitch, and volume are exposed under those weakly specified, but typically used names by gnome-speech.
Parameters:
  • num_groups (integer) - Number of sematic groups the requestor would like to represent using distinct styles
  • num_layers (integer) - Number of content origins (e.g. output originating from a background task versus the focus) the requestor would like to represent using distinct styles
Returns: list of AEOutput.Style
Styles

Class Variable Details [hide private]

DEVICE_IID

Interface identifier for the gnome-speech device. Defaults to None and should be overridden in a subclass.
Type:
string
Value:
None