mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
fail gracefully in winrt voice list fails to load
If no voices are installed, get_all_voices() throws a "file not found" error.
This commit is contained in:
parent
873a27641f
commit
68390eccde
1 changed files with 5 additions and 1 deletions
|
@ -531,7 +531,11 @@ if isWin:
|
||||||
def import_voices(self) -> None:
|
def import_voices(self) -> None:
|
||||||
import winrt.windows.media.speechsynthesis as speechsynthesis # type: ignore
|
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]:
|
def get_available_voices(self) -> List[TTSVoice]:
|
||||||
t = threading.Thread(target=self.import_voices)
|
t = threading.Thread(target=self.import_voices)
|
||||||
|
|
Loading…
Reference in a new issue