1

Is there a way to decrease the time between two engine.say()s in pyttsx3? I want my program to speak words individually so that I can vary the time between each word, but I have not found a way to do this. Here is my current code which does not really do anything, just says each word after the last.

import pyttsx3


engine = pyttsx3.init()
engine.say('Next word')
engine.say('Next word')
engine.say('Next word')
engine.say('Next word')
engine.say('Next word')
engine.say('Next word')
engine.say('Next word')
engine.say('Next word')
engine.runAndWait()
Mason Choi
  • 101
  • 2
  • 12
  • I too am looking for a solution to this but haven't found one yet. The first answer should work, but the problem is that .runAndWait() inexplicably adds so much time. It's quite annoying given that this is quite a simple thing to code in Mathematica. – ngc1300 Mar 12 '22 at 23:31

2 Answers2

0

Regarding the documentation pausing is not provided easily: https://pyttsx3.readthedocs.io/en/latest/engine.html

You could use some sleep between each say:

import pyttsx3
import time


engine = pyttsx3.init()
engine.say('Next word')
engine.runAndWait()
time.sleep(1)
engine.say('Next word')
engine.runAndWait()
  • The problem with this is that the time in between words cannot be made any less than the time that .runAndWait() takes. – ngc1300 Mar 12 '22 at 23:31
-1
import pyttsx3 as tts #Text To Speech

engine = tts.init()
rate = engine.getProperty('rate')
engine.setProperty('rate',rate-100) #increase the space between words here
engine.say("Word 1, Word 2, Word 3, Word 4, etc.")
engine.runAndWait()
  • It helps more if you supply an explanation why this is the preferred solution and explain how it works. We want to educate, not just provide code. – the Tin Man Sep 28 '21 at 19:50
  • This is not a good answer because this code also slows down the pronunciation of the words. It is preferable to have the words spoken at a normal pace. – ngc1300 Mar 12 '22 at 23:28