-1

I want to changing voices and speech rate in pyttsx3

engine = pyttsx3.init()
voices = engine.getProperty('voices')

engine.setProperty('voice', voices[1].id)
        #And
engine.setProperty('rate', 150)

1 Answers1

0

This is the code I use for a Mac. If you have a Windows computer, I don't know if it will work. Ok, here is the code to change the rate:

import pyttsx3    
engine = pyttsx3.init()
rate = engine.getProperty('rate')
engine.setProperty('rate', put the rate you want)
engine.setProperty('voice', 'com.apple.speech.synthesis.voice.Alex')
engine.say("what you want to say goes here")
    
engine.runAndWait()

Here is the code to finding other voices. Put what you want it to say for every one of the voices. Then if you find one that works, copy it and put it into where it says .com.apple.speech.synthesis.voice.Alex on the code example above.

import pyttsx3
engine = pyttsx3.init()
voices = engine.getProperty('voices')
for voice in voices:
    print(voice, voice.id)
    engine.setProperty('voice', voice.id)
    engine.say("Hello World!")
    engine.runAndWait()
    engine.stop()

Let me know if it works.

AstroGuy
  • 56
  • 6
  • import pyttsx3 engine = pyttsx3.init() rate = engine.getProperty('rate') engine.setProperty('rate', put the rate you want) engine.setProperty('voice', 'put the voice you want') engine.say("what you want to say goes here") engine.runAndWait() – AstroGuy Jan 23 '22 at 23:42