From 68390eccde446cb095ae69a916a4e2a78b7602bb Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 21 Dec 2020 14:23:10 +1000 Subject: [PATCH] fail gracefully in winrt voice list fails to load If no voices are installed, get_all_voices() throws a "file not found" error. --- qt/aqt/tts.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qt/aqt/tts.py b/qt/aqt/tts.py index 467b6ee07..2f47a17c2 100644 --- a/qt/aqt/tts.py +++ b/qt/aqt/tts.py @@ -531,7 +531,11 @@ if isWin: def import_voices(self) -> None: import winrt.windows.media.speechsynthesis as speechsynthesis # type: ignore - self.voice_list = speechsynthesis.SpeechSynthesizer.get_all_voices() + try: + self.voice_list = speechsynthesis.SpeechSynthesizer.get_all_voices() + except Exception as e: + print("winrt tts voices unavailable:", e) + self.voice_list = [] def get_available_voices(self) -> List[TTSVoice]: t = threading.Thread(target=self.import_voices)