pyttsx3 varying time between spoken words

889 views Asked by At

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()
2

There are 2 answers

1
Antoine Feuillet On

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()
2
prestonzen On
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()