Python Forum
Controlling text-to-speech pauses with pyttsx3
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Controlling text-to-speech pauses with pyttsx3
#1
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?
Yoriz write Mar-12-2022, 11:52 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#2
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()
BashBedlam likes this post
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
Now it is too fast. And changing the 'rate' parameter doesn't help either because it slows down the word too.
Reply
#4
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()
 
menator01 likes this post
Reply
#5
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
I speak Python but I don't speak English (I just read it a little). If I express myself badly, please blame the translator^^.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Controlling program with TCP commands lavacode 1 554 Jul-10-2023, 04:39 PM
Last Post: deanhystad
  pyttsx3 cutting off last word Extra 3 2,920 Feb-28-2022, 11:20 PM
Last Post: BashBedlam
  pyttsx3 problem Tyrel 0 1,118 Feb-05-2022, 08:53 AM
Last Post: Tyrel
  Controlling what get outputted to stdout when running external commands Daring_T 4 2,179 Jan-30-2022, 05:40 PM
Last Post: bowlofred
  Know when the pyttsx3 engine stops talking UsualCoder 3 3,239 Aug-29-2021, 11:08 PM
Last Post: snippsat
  Speech Recognition with timestamps DeanAseraf1 3 6,620 Jun-27-2021, 06:58 PM
Last Post: gh_ad
  working with pyttsx3 gr3yali3n 0 1,613 Nov-24-2020, 09:40 AM
Last Post: gr3yali3n
  Continous Speech Recognition dell91 0 1,840 Oct-29-2020, 10:51 AM
Last Post: dell91
  How to Split Output Audio on Text to Speech Code Base12 2 6,880 Aug-29-2020, 03:23 AM
Last Post: Base12
  Looking For Help On Controlling Philips Hue From PyCharm RickyRay333 4 3,804 Aug-24-2020, 08:33 PM
Last Post: Nickd12

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020