Feb-28-2022, 11:20 PM
(Feb-28-2022, 10:33 PM)Extra Wrote: I have one other question though. Is it possible to have my speech output run as the text is being displayed on the screen (through the auto-type/typewriter animation). Right now the text will "typewrite" to the screen, then the speech output will start. Is there anyway the can work simultaneously?This would be my best shot at that.
import sys import time import pyttsx3 import threading engine = pyttsx3.init () engine.setProperty ('rate', 120) def tell (*output_array) : output_string = ' '.join (output_array) engine.say (output_string) engine.runAndWait () def show_and_tell (output_string) : output_array = output_string.split () telling = threading.Thread (target = tell, args = (output_array)) telling.start () for letter in output_string : print (letter, end = '') sys.stdout.flush () time.sleep (0.08) print () show_and_tell ('How may I be of service?')