EyeTrackVR/RANSACApp/speech_engine.py
Kyle Machulis 71abcd4a06 Start building new RANSAC App with multiple modules and unified GUI
Divide out utilities from main algorithm, set utilities on their own
threads. Reference binaries in original directory so we don't have to
duplicate them in the repo.
2022-06-05 20:19:39 -07:00

25 lines
542 B
Python

import pyttsx3
import queue
import threading
class SpeechEngine:
def __init__(self, queue: "queue.Queue[str | None]"):
self.engine = pyttsx3.init()
self.queue = queue
def say(self, item):
self.engine.say(item)
def force_stop(self):
self.engine.stop()
def run(self):
while True:
print("Waiting for speech item")
item = self.queue.get()
if item is None:
print("Stopping speech engine")
self.engine.stop()
return
self.engine.say(item)
self.engine.runAndWait()