mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 07:52:24 -04:00
Handle the case where win32com.client fails to import
Hopefully fixes the "no attribute 'Flags'" issue: https://forums.ankiweb.net/t/technical-issue-with-anki-desktop/27089
This commit is contained in:
parent
bf10bbbb62
commit
d6a18d2d71
1 changed files with 4 additions and 3 deletions
|
@ -266,8 +266,6 @@ class WindowsVoice(TTSVoice):
|
||||||
|
|
||||||
|
|
||||||
if is_win:
|
if is_win:
|
||||||
import win32com.client # pylint: disable=import-error
|
|
||||||
|
|
||||||
# language ID map from https://github.com/sindresorhus/lcid/blob/master/lcid.json
|
# language ID map from https://github.com/sindresorhus/lcid/blob/master/lcid.json
|
||||||
LCIDS = {
|
LCIDS = {
|
||||||
"4": "zh_CHS",
|
"4": "zh_CHS",
|
||||||
|
@ -482,8 +480,11 @@ if is_win:
|
||||||
class WindowsTTSPlayer(TTSProcessPlayer):
|
class WindowsTTSPlayer(TTSProcessPlayer):
|
||||||
default_rank = -1
|
default_rank = -1
|
||||||
try:
|
try:
|
||||||
|
import win32com.client # pylint: disable=import-error
|
||||||
|
|
||||||
speaker = win32com.client.Dispatch("SAPI.SpVoice")
|
speaker = win32com.client.Dispatch("SAPI.SpVoice")
|
||||||
except:
|
except Exception as exc:
|
||||||
|
print("unable to activate sapi:", exc)
|
||||||
speaker = None
|
speaker = None
|
||||||
|
|
||||||
def get_available_voices(self) -> list[TTSVoice]:
|
def get_available_voices(self) -> list[TTSVoice]:
|
||||||
|
|
Loading…
Reference in a new issue