Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make pyttsx module's voice go slower

My code:

import pyttsx3
import random

engine = pyttsx3.init()
words = ['hello', 'word']     
engine.say(random.choice(words)) #Say these words slower

I don't want it to go really slow just slow enough to be easy for a non native speaker to undersatnd the words in the words list. Also if it is impossible to do it using the pyttsx module can you suggest a module that can do that?

like image 225
Vagos A. Avatar asked Sep 05 '17 12:09

Vagos A.


People also ask

How many voices does pyttsx3 have?

The pyttsx3 module supports two voices first is female and the second is male which is provided by “sapi5” for windows.

How do you change the voice in Python?

On the run of the python file, the voiceChange() function is invoked. Inside the function, an instance is initialized of the module. In the voices library, we get the available voices, and then using the setProperty() method, we change the voice id accordingly to bring a male or female voice.


2 Answers

newVoiceRate = 145
engine.setProperty('rate',newVoiceRate)
like image 191
Sarborup Sarkar Avatar answered Oct 06 '22 09:10

Sarborup Sarkar


Try this:

engine.setProperty('rate', newVoiceRate)

Replace newVoiceRate with rate according to requirement. It's integer speech rate in words per minute. Defaults to 200 word per minute.

like image 30
Rahul Vansh Avatar answered Oct 06 '22 08:10

Rahul Vansh