mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
parent
9c54f85be6
commit
8ca2fa6476
1 changed files with 13 additions and 8 deletions
|
@ -474,9 +474,10 @@ if is_win:
|
|||
"31748": "zh_CHT",
|
||||
}
|
||||
|
||||
def lcid_hex_str_to_lang_code(hex: str) -> str:
|
||||
dec_str = str(int(hex, 16))
|
||||
return LCIDS.get(dec_str, "unknown")
|
||||
def lcid_hex_str_to_lang_codes(hex_codes: str) -> list[str]:
|
||||
return [
|
||||
LCIDS.get(str(int(code, 16)), "unknown") for code in hex_codes.split(";")
|
||||
]
|
||||
|
||||
class WindowsTTSPlayer(TTSProcessPlayer):
|
||||
default_rank = -1
|
||||
|
@ -488,13 +489,17 @@ if is_win:
|
|||
def get_available_voices(self) -> list[TTSVoice]:
|
||||
if self.speaker is None:
|
||||
return []
|
||||
return list(map(self._voice_to_object, self.speaker.GetVoices()))
|
||||
return [
|
||||
obj
|
||||
for voice in self.speaker.GetVoices()
|
||||
for obj in self._voice_to_objects(voice)
|
||||
]
|
||||
|
||||
def _voice_to_object(self, voice: Any) -> WindowsVoice:
|
||||
lang = voice.GetAttribute("language")
|
||||
lang = lcid_hex_str_to_lang_code(lang)
|
||||
def _voice_to_objects(self, voice: Any) -> list[WindowsVoice]:
|
||||
langs = voice.GetAttribute("language")
|
||||
langs = lcid_hex_str_to_lang_codes(langs)
|
||||
name = self._tidy_name(voice.GetAttribute("name"))
|
||||
return WindowsVoice(name=name, lang=lang, handle=voice)
|
||||
return [WindowsVoice(name=name, lang=lang, handle=voice) for lang in langs]
|
||||
|
||||
def _play(self, tag: AVTag) -> None:
|
||||
assert isinstance(tag, TTSTag)
|
||||
|
|
Loading…
Reference in a new issue