productionbotscreen changed
This commit is contained in:
31
pds.py
31
pds.py
@@ -276,48 +276,19 @@ class ProductionBotScreen(QWidget):
|
|||||||
self.plant_map = {}
|
self.plant_map = {}
|
||||||
self.awaiting_plants = False
|
self.awaiting_plants = False
|
||||||
|
|
||||||
# Threading imports required at top of your file:
|
|
||||||
# import queue, threading
|
|
||||||
|
|
||||||
self.init_tts()
|
self.init_tts()
|
||||||
self._setup_ui()
|
self._setup_ui()
|
||||||
|
|
||||||
QTimer.singleShot(500, self._show_greeting)
|
QTimer.singleShot(500, self._show_greeting)
|
||||||
QTimer.singleShot(1500, self.load_charts)
|
QTimer.singleShot(1500, self.load_charts)
|
||||||
|
|
||||||
# TTS queue and worker thread for safe speech
|
|
||||||
self.tts_queue = queue.Queue()
|
self.tts_queue = queue.Queue()
|
||||||
self.tts_thread = threading.Thread(target=self.tts_worker, daemon=True)
|
self.tts_thread = threading.Thread(target=self.tts_worker, daemon=True)
|
||||||
self.tts_thread.start()
|
self.tts_thread.start()
|
||||||
|
|
||||||
def tts_worker(self):
|
|
||||||
while True:
|
|
||||||
text = self.tts_queue.get()
|
|
||||||
if text is None:
|
|
||||||
break
|
|
||||||
try:
|
|
||||||
self.tts_engine.say(text)
|
|
||||||
self.tts_engine.runAndWait()
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
self.tts_queue.task_done()
|
|
||||||
|
|
||||||
def speak(self, text):
|
|
||||||
self.tts_queue.put(text)
|
|
||||||
|
|
||||||
def closeEvent(self, event):
|
|
||||||
self.tts_queue.put(None)
|
|
||||||
self.tts_thread.join(timeout=2)
|
|
||||||
super().closeEvent(event)
|
|
||||||
|
|
||||||
def init_tts(self):
|
def init_tts(self):
|
||||||
self.tts_engine = pyttsx3.init()
|
self.tts_engine = pyttsx3.init()
|
||||||
self.tts_engine.setProperty('rate', 170)
|
self.tts_engine.setProperty('rate', 170)
|
||||||
voices = self.tts_engine.getProperty('voices')
|
|
||||||
for voice in voices:
|
|
||||||
if "female" in voice.name.lower() or "zira" in voice.name.lower():
|
|
||||||
self.tts_engine.setProperty('voice', voice.id)
|
|
||||||
break
|
|
||||||
|
|
||||||
def _setup_ui(self):
|
def _setup_ui(self):
|
||||||
layout = QVBoxLayout(self)
|
layout = QVBoxLayout(self)
|
||||||
@@ -456,7 +427,7 @@ class ProductionBotScreen(QWidget):
|
|||||||
self.speak("Please enter a valid number.")
|
self.speak("Please enter a valid number.")
|
||||||
|
|
||||||
def load_charts(self):
|
def load_charts(self):
|
||||||
url = "https://pds.iotsignin.com/api/get/modulechart-name/data" # Correct API URL
|
url = "https://pds.iotsignin.com/api/get/modulechart-name/data"
|
||||||
headers = {
|
headers = {
|
||||||
"Authorization": "Bearer sb-eba140ab-74bb-44a4-8d92-70a636940def!b1182|it-rt-dev-cri-stjllphr!b68:616d8991-307b-4ab1-be37-7894a8c6db9d$0p0fE2I7w1Ve23-lVSKQF0ka3mKrTVcKPJYELr-i4nE=",
|
"Authorization": "Bearer sb-eba140ab-74bb-44a4-8d92-70a636940def!b1182|it-rt-dev-cri-stjllphr!b68:616d8991-307b-4ab1-be37-7894a8c6db9d$0p0fE2I7w1Ve23-lVSKQF0ka3mKrTVcKPJYELr-i4nE=",
|
||||||
"module-name": "Production DashBoard"
|
"module-name": "Production DashBoard"
|
||||||
|
|||||||
Reference in New Issue
Block a user