[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] TTS and Pitch Parameter
I'm afraid I don't understand - so the script you emailed works fine
for you in python 2.5 on your windows box, right?
So then what exactly doesn't work? I still don't get why you think
pygame is involved...
On Fri, Mar 7, 2008 at 3:45 PM, FT <chester_lab@xxxxxxxx> wrote:
> Below is the speech.py file which will load in python25 from my windows
> OS. It uses the same command as in the pygame example, no different. So, the
> same import should be in affect, except if pygame uses these same commands,
> the pitch does not work.
> import pyTTS
> import time
> tts = pyTTS.Create()
>
> # set the speech rate, higher value = faster
> # just for fun try values of -10 to 10
> tts.Rate = 3
> print "Speech rate =", tts.Rate
>
> #NOW SET THE PITCH!
> tts.Pitch = 3
> print "Speech pitch =", tts.Pitch
>
> # set the speech volume percentage (0-100%)
> tts.Volume = 90
> print "Speech volume =", tts.Volume
>
> tts.SetVoiceByName('MSSam')
> print "Voice is now set to Sam!"
> tts.Speak("The speech rate is: ")
> tts.Speak(tts.Rate)
> tts.Speak("The speech pitch is: ")
> tts.Speak(tts.Pitch)
> tts.Speak("The speech volume is:")
> tts.Speak(tts.Volume)
> print
>
> # get a list of all the available voices
> tts.Speak("The List Of Voices Are: ")
> tts.Speak(tts.GetVoiceNames())
> print "List of voices =", tts.GetVoiceNames()
>
> # explicitly set a voice
> tts.SetVoiceByName('MSMary')
> print "Voice is set to Mary"
> print
> # announce the date and time, does a good job
> timeStr = "The date and time is " + time.asctime()
> print timeStr
> tts.Speak(timeStr)
> print
>
> str1 = """
> A young executive was leaving the office at 6 pm when he found
> the CEO standing in front of a shredder with a piece of paper in hand.
> "Listen," said the CEO, "this is important, and my secretary has left.
> Can you make this thing work?"
> "Certainly," said the young executive. He turned the machine on,
> inserted the paper, and pressed the start button.
> "Excellent, excellent!" said the CEO as his paper disappeared inside
> the machine. "I just need one copy."
> """
> print str1
> tts.Speak(str1)
> tts.Speak('Haah haa, haah, haa!')
> print
>
> tts.SetVoiceByName('MSMike')
> tts.Speak("Now we are using Mike's voice!")
>
> str2 = """
> Finagle's fourth law:
> Once a job is fouled up, anything done to improve it only makes it worse.
> """
> print str2
> print
> print "The spoken text above has been written to a wave file (.wav)"
> tts.Speak("Now sending text to a wav file!")
> tts.SpeakToWave('Finagle4.wav', str2)
> print "The wave file is loaded back and spoken ..."
> tts.Speak("Now speaking the wav file: ")
> tts.SpeakFromWave('Finagle4.wav')
> print
>
> print "Substitute a hard to pronounce word like Ctrl key ..."
> #create an instance of the pronunciation corrector
> p = pyTTS.Pronounce()
> # replace words that are hard to pronounce with something that
> # is spelled out or misspelled, but at least sounds like it
> p.AddMisspelled('Ctrl', 'Control')
> str3 = p.Correct('Please press the Ctrl key!')
> tts.Speak(str3)
> print
>
> print "2 * 3 = 6"
> tts.Speak('2 * 3 = 6')
> print
> tts.Speak("sounds goofy, let's replace * with times")
> print "Substitute * with times"
> # ' * ' needs the spaces
> p.AddMisspelled(' * ', 'times')
> str4 = p.Correct('2 * 3 = 6')
> tts.Speak(str4)
> print
>
> print "Say that real fast a few times!"
> str5 = "The sinking steamer sunk!"
> tts.Rate = 6
> for k in range(4):
> print str5
> tts.Speak(str5)
> time.sleep(0.2)
> tts.Rate = 0
>
> tts.Pitch = 1
> tts.SetVoiceByName("MSSam")
> tts.Speak("Wow, not one mispronounced word!")
>
>