Yet another attempt and handling charsets.

This commit is contained in:
Storm Dragon 2025-01-25 10:56:27 -05:00
parent a0e539d3ce
commit 78f7ae506d

View File

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