Handle missing attributes in win32 tts code

https://forums.ankiweb.net/t/trouble-adding-tts-to-my-cards/21792/4
This commit is contained in:
Damien Elmes 2022-07-30 19:08:37 +10:00
parent 2e2fc799e2
commit d699bc1252

View file

@ -496,9 +496,18 @@ if is_win:
]
def _voice_to_objects(self, voice: Any) -> list[WindowsVoice]:
langs = voice.GetAttribute("language")
try:
langs = voice.GetAttribute("language")
except:
# no associated language; ignore
return []
langs = lcid_hex_str_to_lang_codes(langs)
name = self._tidy_name(voice.GetAttribute("name"))
try:
name = voice.GetAttribute("name")
except:
# some voices may not have a name
name = "unknown"
name = self._tidy_name(name)
return [WindowsVoice(name=name, lang=lang, handle=voice) for lang in langs]
def _play(self, tag: AVTag) -> None: