Я пытаюсь использовать Pyttsx3 для воспроизведения трех сообщений с помощью преобразования текста в речь. Однако воспроизводится только первое сообщение. Как мне сыграть во все три? В настоящее время я использую Python 3.11 на VSC
#Imports
import time as t
import os
import pyttsx3
#tts
engine = pyttsx3.init()
engine.setProperty('rate', 150)
engine.setProperty('volume', 1)
rate=engine.getProperty('rate')
volume=engine.getProperty('volume')
voices=engine.getProperty('voices')
if len(voices) > 1:
engine.setProperty('voice', voices[1].id)
else:
engine.setProperty('voice', voices[0].id)
#functions
def clear():
os.system('cls' if os.name == 'nt' else 'clear')
def tts(text):
engine.say(text)
engine.runAndWait()
t.sleep(0.5)
# program
clear()
t.sleep(0.5)
tts("Well hello!, Welcome to Walfenix's program!. This place is a little dusty tho... hmm... hold on")
print("Initializing...")
t.sleep(2)
clear()
tts("There we go, much better!")
print("Done!")
tts("This is a test message to see if the voice works.")
Подробнее здесь: https://stackoverflow.com/questions/798 ... e-of-three