Python Forum

Full Version: Controlling text-to-speech pauses with pyttsx3
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a list of words that I want Python to turn into speech:

import pyttsx3
import time

words = ['this','is','my','list']

engine = pyttsx3.init()

for i in words:
    engine.say(i)
    engine.runAndWait()
    time.sleep(0)
Currently, the time between each word is too long (over a second), even with time.sleep set to 0. Why does the .runAndWait() method even have a built-in wait time and how can this delay be decreased?
Instead of looping the list of words, maybe join them.

import pyttsx3

words = ['this','is','my','list']
join_words = ' '.join(words)

engine = pyttsx3.init()

engine.say(join_words)
engine.runAndWait()
Now it is too fast. And changing the 'rate' parameter doesn't help either because it slows down the word too.
You can create small pauses after each word by inserting commas like this:
import pyttsx3

words = ['this,','is,','my,','list']
join_words = ' '.join(words)
engine = pyttsx3.init()
engine.say(join_words)
engine.runAndWait()
 
Hello,
(Mar-13-2022, 04:31 PM)BashBedlam Wrote: [ -> ]You can create small pauses after each word by inserting commas like this:
import pyttsx3

words = ['this,','is,','my,','list']
join_words = ' '.join(words)
engine = pyttsx3.init()
engine.say(join_words)
engine.runAndWait()
 

words = ['this','is','my','list']
join_words = ', '.join(words)
Sleepy