Module synthDriverHandler :: Class SynthDriver
[hide private]
[frames] | no frames]

Class SynthDriver

source code

                   object --+    
                            |    
baseObject.AutoPropertyObject --+
                                |
                               SynthDriver

Abstract base synthesizer driver. Each synthesizer driver should be a separate Python module in the root synthDrivers directory containing a SynthDriver class which inherits from this base class.

At a minimum, synth drivers must set name and description and override the check method. supportedSettings should be set as appropriate for the settings supported by the synthesiser. There are factory functions to create SynthSetting instances for common settings; e.g. VoiceSetting and RateSetting. The properties for each setting (e.g. voice and pitch) are created by overriding getters and setters; for example, _get_pitch and _set_pitch for pitch. The methods speakText, speakCharacter, cancel and pause should be overridden as appropriate. If speakCharacter is not overridden, speakText will be used by default.

Nested Classes [hide private]

Inherited from baseObject.AutoPropertyObject: __metaclass__

Instance Methods [hide private]
 
__init__(self)
Initialize this synth driver.
source code
 
terminate(self)
Terminate this synth driver.
source code
 
speak(self, speechSequence)
Speaks the given sequence of text and speech commands.
source code
 
speakText(self, text, index=None)
Speak some text.
source code
 
speakCharacter(self, character, index=None)
Speak some character.
source code
int
_get_lastIndex(self)
Obtain the index of the chunk of text which was last spoken.
source code
 
cancel(self)
Silence speech immediately.
source code
 
_get_language(self) source code
 
_set_language(self, language) source code
 
_get_availableLanguages(self) source code
 
_get_voice(self) source code
 
_set_voice(self, value) source code
OrderedDict
_getAvailableVoices(self)
fetches an ordered dictionary of voices that the synth supports.
source code
 
_get_availableVoices(self) source code
 
_get_rate(self) source code
 
_set_rate(self, value) source code
 
_get_pitch(self) source code
 
_set_pitch(self, value) source code
 
_get_volume(self) source code
 
_set_volume(self, value) source code
 
_get_variant(self) source code
 
_set_variant(self, value) source code
OrderedDict
_getAvailableVariants(self)
fetches an ordered dictionary of variants that the synth supports, keyed by ID
source code
 
_get_availableVariants(self) source code
 
_get_supportedSettings(self) source code
 
getConfigSpec(self) source code
 
_get_inflection(self) source code
 
_set_inflection(self, value) source code
 
pause(self, switch)
Pause or resume speech output.
source code
l{bool}
isSupported(self, settingName)
Checks whether given setting is supported by the synthesizer.
source code
 
saveSettings(self) source code
 
loadSettings(self) source code
 
_get_initialSettingsRingSetting(self) source code

Inherited from baseObject.AutoPropertyObject: invalidateCache

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

Class Methods [hide private]
 
LanguageSetting(cls)
Factory function for creating a language setting.
source code
 
VoiceSetting(cls)
Factory function for creating voice setting.
source code
 
VariantSetting(cls)
Factory function for creating variant setting.
source code
 
RateSetting(cls, minStep=1)
Factory function for creating rate setting.
source code
 
VolumeSetting(cls, minStep=1)
Factory function for creating volume setting.
source code
 
PitchSetting(cls, minStep=1)
Factory function for creating pitch setting.
source code
 
InflectionSetting(cls, minStep=1)
Factory function for creating inflection setting.
source code
bool
check(cls)
Determine whether this synth is available.
source code
 
_paramToPercent(cls, current, min, max)
Convert a raw parameter value to a percentage given the current, minimum and maximum raw values.
source code
 
_percentToParam(cls, percent, min, max)
Convert a percentage to a raw parameter value given the current percentage and the minimum and maximum raw parameter values.
source code

Inherited from baseObject.AutoPropertyObject: invalidateCaches

Class Variables [hide private]
  name = ""
  description = ""

Inherited from baseObject.AutoPropertyObject: cachePropertiesByDefault

Instance Variables [hide private]
OrderedDict of [VoiceInfo keyed by VoiceInfo's ID availableVariants
The available variants of the voice.
OrderedDict of VoiceInfo keyed by VoiceInfo's ID availableVoices
The available voices.
int inflection
The current inflection; ranges between 0 and 100.
int lastIndex
The index of the chunk of text which was last spoken or None if no index.
int pitch
The current pitch; ranges between 0 and 100.
int rate
The current rate; ranges between 0 and 100.
list or tuple of SynthSetting supportedSettings
The settings supported by the synthesiser.
str variant
The current variant of the voice.
str voice
Unique string identifying the current voice.
int volume
The current volume; ranges between 0 and 100.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

check(cls)
Class Method

source code 

Determine whether this synth is available. The synth will be excluded from the list of available synths if this method returns False. For example, if this synth requires installation and it is not installed, False should be returned.

Returns: bool
True if this synth is available, False if not.

__init__(self)
(Constructor)

source code 

Initialize this synth driver. This method can also set default settings for the synthesizer.

Raises:
  • Exception - If an error occurs.
Overrides: object.__init__

Postcondition: This driver can be used.

terminate(self)

source code 

Terminate this synth driver. This should be used for any required clean up.

Precondition: initialize has been called.

Postcondition: This driver can no longer be used.

speak(self, speechSequence)

source code 

Speaks the given sequence of text and speech commands. This base implementation will fallback to making use of the old speakText and speakCharacter methods. But new synths should override this method to support its full functionality.

Parameters:
  • speechSequence (list of string and speechCommand) - a list of text strings and SpeechCommand objects (such as index and parameter changes).

speakText(self, text, index=None)

source code 

Speak some text. This method is deprecated. Instead implement speak.

Parameters:
  • text (str) - The chunk of text to speak.
  • index (int) - An index (bookmark) to associate with this chunk of text, None if no index.

Note: If index is provided, the lastIndex property should return this index when the synth is speaking this chunk of text.

speakCharacter(self, character, index=None)

source code 

Speak some character. This method is deprecated. Instead implement speak.

Parameters:
  • character (str) - The character to speak.
  • index (int) - An index (bookmark) to associate with this chunk of speech, None if no index.

Note: If index is provided, the lastIndex property should return this index when the synth is speaking this chunk of text.

_get_lastIndex(self)

source code 

Obtain the index of the chunk of text which was last spoken. When the synth speaks text associated with a particular index, this method should return that index. That is, this property should update for each chunk of text spoken by the synth.

Returns: int
The index or None if no index.

_getAvailableVoices(self)

source code 

fetches an ordered dictionary of voices that the synth supports.

Returns: OrderedDict
an OrderedDict of VoiceInfo instances representing the available voices, keyed by ID

_getAvailableVariants(self)

source code 

fetches an ordered dictionary of variants that the synth supports, keyed by ID

Returns: OrderedDict
an ordered dictionary of VoiceInfo instances representing the available variants

pause(self, switch)

source code 

Pause or resume speech output.

Parameters:
  • switch (bool) - True to pause, False to resume (unpause).

_paramToPercent(cls, current, min, max)
Class Method

source code 

Convert a raw parameter value to a percentage given the current, minimum and maximum raw values.

Parameters:
  • current (int) - The current value.
  • min - The minimum value.
  • max (int) - The maximum value.

_percentToParam(cls, percent, min, max)
Class Method

source code 

Convert a percentage to a raw parameter value given the current percentage and the minimum and maximum raw parameter values.

Parameters:
  • percent (int) - The current percentage.
  • min (int) - The minimum raw parameter value.
  • max (int) - The maximum raw parameter value.