How to make pyttsx module's voice go slower
Asked Answered
D

4

13

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?

Dryden answered 5/9, 2017 at 12:27 Comment(4)
words = ['heeeeeeeeeellllllllllllllllloooooooooo', 'woooooooorrrrrrrrrrrddd'] ;)Lysias
@Lysias in that specific module the voice literally says what you type so it says: (1x)h,(10x)e,(17x)l,(10x)oDryden
Yes sorry it was a joke! I'm not familiar with the module so can't help I'm afraidLysias
@Lysias oh ok lol I didn't get it xDDryden
L
17
newVoiceRate = 145
engine.setProperty('rate',newVoiceRate)
Lila answered 12/2, 2020 at 7:1 Comment(2)
Welcome to SO. Please explain your answer. For more information about writing good answers, see stackoverflow.com/help/answeringSorcerer
Yes i agree with @Alfie, please explain your answer.Nynorsk
G
7

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.

Geek answered 15/5, 2018 at 13:1 Comment(0)
K
3

To make the voice go slower in pyttsx3 you can just do:

import pyttsx3   

text = "Hello"
 
engine = pyttsx3.init()
engine.setProperty("rate", rate)
engine.say(text)
engine.runAndWait()

Kamasutra answered 10/9, 2020 at 7:31 Comment(0)
E
2

First We Have To Make A Variable Which defines the rate of speed the engine have to speak the (engine.setProperty) sets The Property of the rate to the variable (newVoiceRate) By That You Can change The Speed of speaking speed of the engine. I have Also Edited your codes and implied the changes. See below Try This

 import pyttsx3
 import random

 engine = pyttsx3.init()
 words = ['hello', 'word']     
 engine.say(random.choice(words))
 newVoiceRate = 145
 engine.setProperty('rate',newVoiceRate)
Earthworm answered 12/8, 2020 at 6:10 Comment(3)
While this code may provide a solution to the question, it's better to add context as to why/how it works. This can help future users learn, and apply that knowledge to their own code. You are also likely to have positive feedback from users in the form of upvotes, when the code is explained.Handpick
Thanks for Sharing Your Feedback next time I will try to improve answersEarthworm
I Have Edited the Answer and Now it is perfect. If You Like my Answers Please see my profile once Becouse I am a beginner in ProgrammingEarthworm

© 2022 - 2024 — McMap. All rights reserved.