diff --git a/Toby Doom Launcher.py b/Toby Doom Launcher.py index d002f57..b7831f5 100755 --- a/Toby Doom Launcher.py +++ b/Toby Doom Launcher.py @@ -248,26 +248,33 @@ class SpeechHandler: while True: try: line = process.stdout.readline() - # Keep gzdoom's existing functionality of lines being printed to the console. - print(line, end='') + if not isinstance(line, str): + line = line.decode('utf-8', errors='replace') + if not line: break - + + # Keep gzdoom's existing functionality of lines being printed to the console + print(line, end='', flush=True) + lineStr = line.strip() + if not lineStr: + continue # Wait for the initial separator before starting speech if not startSpeech: - if lineStr and all(c == '-' for c in lineStr): + if all(c == '-' for c in lineStr): startSpeech = True - continue + continue - processedLine = self.process_line(lineStr) - if processedLine: - self.speak(processedLine) + if startSpeech: + processedLine = self.process_line(lineStr) + if processedLine: + self.speak(processedLine) except Exception as e: print(f"Error processing game output: {e}", file=sys.stderr) - break + continue class MenuDialog(QDialog):