Hi!

    I decided to post the voice adjustments in the Star Trek game.
All stuff are inside dictionaries and the Python format is not much different 
then VBScript
    The only difference between languages except more options in Python, is 
that Python requires indentation and no need for an end statement.

    When going into the game a selection is passed in as a command line parm 
and the weVoice is a True or False flag that is set depending on what is seen 
or not seen on the command line argument.

    Below are 2 properties of the GG or Game Global class and the self property 
statement is to indicate calling from within itself...

    The passed in variable is the name of the voice, Computer, Spock, or 
Scotty, or any voice you desire to add to the dictionary.
So the top level key of the dictionary is the name which calls a second 
dictionary.
The parm keys of the voice ar: v for voice, pl for pitch, rl for rate, and vl 
for volume.
These keys calling the stored value inside the dictionary.
Inside the voice adjustment property I use the numerical value and call it's 
respective letter value for the Windoweyes voice version.
But for Sapi I even use the name of the voice placed in the dictionary.
I save the original settings before the game starts and placed them back in at 
the end of the game if needed.
First below are the global inits which are passed in under a different name 
inside the GG, GameGlobal class init:
(In Python the dictionary is initialized and enclosed in {} braces.)
WeTts = CreateObject( "windoweyes.application")
WeOriginalVoice = {"v": WeTts.ActiveSettings.Screen.Tone, "rl": 
WeTts.ActiveSettings.Screen.Rate, "pl": WeTts.ActiveSettings.Screen.Pitch, 
"vl": WeTts.ActiveSettings.Screen.Volume}
WeComputerVoice = {"v": "l", "rl": 62, "pl": 4, "vl": 0}
WeSpockVoice = {"v": "k", "rl": 62, "pl": 4, "vl": 0}
WeScottyVoice = {"v": "s", "rl": 62, "pl": 4, "vl": 0}
WeTtsDict = {"WE": WeTts, "ORG": WeOriginalVoice, "Computer": WeComputerVoice, 
"Spock": WeSpockVoice, "Scotty": WeScottyVoice}

The GG class, GameGlobal property:
(self is to indicate calling itself.)
    def changeVoice(self, name):
        "CHANGE THE VOICE, PITCH, RATE, AND VOLUME!"
        if self.weVoice:
            self.weTalk.ActiveSettings.Screen.Tone = self.weTalkDict[name][ "v"]
            self.weTalk.ActiveSettings.Screen.Rate = self.weTalkDict[name][ 
"rl"]
            self.weTalk.ActiveSettings.Screen.Pitch = self.weTalkDict[name][ 
"pl"]
            self.weTalk.ActiveSettings.Screen.Volume = self.weTalkDict[name][ 
"vl"]
        else:
            self._pitch = self.v4Talk[name][ "pl"]
            self.talk.setRate( self.v4Talk[name][ "rl"])
            self.talk.setVolume( self.v4Talk[name][ "vl"])
            self.talk.setVoiceByName( self.v4Talk[name][ "v"])

    def adjustVoice(self, name):
        "ADJUST  THE VOICE, PITCH, RATE, AND VOLUME!"
        choices= "v", "rl", "pl", "vl"
        voices = "abcdefghijklmnopqrstuvwxyz"
        if self.weVoice:
            type= {"v":{"n":"tone", "b":0, "e":25}, "rl":{"n":"rate", "b":1, 
"e":100}, "vl":{"n":"volume", "b":0, "e":9}, "pl":{"n":"pitch", "b":0, "e":9}}
        else:
            type= {"v":{"n":"voice", "b":0, "e":self._voiceCount-1}, 
"rl":{"n":"rate", "b":-10, "e":10}, "vl":{"n":"volume", "b":0, "e":100}, 
"pl":{"n":"pitch", "b":-10, "e":10}}
...
Above are boundaries of the adjustments allowed for both WE and Sapi voices.
So, depending on the order position of your adjustments those boundaries are 
called and used.

Reply via email to