From a30064d5e9df07b0458d26a3c8e8112c5e64e58b Mon Sep 17 00:00:00 2001 From: Ryan Aird Date: Sun, 20 Dec 2020 19:43:09 -0600 Subject: [PATCH] Make RT import statement conditional, fix formatting, ignore WinRT for type checking --- qt/aqt/sound.py | 4 +++- qt/aqt/tts.py | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/qt/aqt/sound.py b/qt/aqt/sound.py index 1b44adebc..64fdc6304 100644 --- a/qt/aqt/sound.py +++ b/qt/aqt/sound.py @@ -917,11 +917,13 @@ def setup_audio(taskman: TaskManager, base_folder: str) -> None: av_player.players.append(MacTTSPlayer(taskman)) elif isWin: - from aqt.tts import WindowsRTTTSFilePlayer, WindowsTTSPlayer + from aqt.tts import WindowsTTSPlayer av_player.players.append(WindowsTTSPlayer(taskman)) if platform.release() == "10": + from aqt.tts import WindowsRTTTSFilePlayer + # If Windows 10, ensure it's October 2018 update or later if int(platform.version().split(".")[-1]) >= 17763: av_player.players.append(WindowsRTTTSFilePlayer(taskman)) diff --git a/qt/aqt/tts.py b/qt/aqt/tts.py index 2536a8d56..467b6ee07 100644 --- a/qt/aqt/tts.py +++ b/qt/aqt/tts.py @@ -529,7 +529,7 @@ if isWin: tmppath = os.path.join(tmpdir(), "tts.wav") def import_voices(self) -> None: - import winrt.windows.media.speechsynthesis as speechsynthesis + import winrt.windows.media.speechsynthesis as speechsynthesis # type: ignore self.voice_list = speechsynthesis.SpeechSynthesizer.get_all_voices() @@ -569,8 +569,8 @@ if isWin: cb() async def speakText(self, tag: TTSTag, voice_id): - import winrt.windows.media.speechsynthesis as speechsynthesis - import winrt.windows.storage.streams as streams + import winrt.windows.media.speechsynthesis as speechsynthesis # type: ignore + import winrt.windows.storage.streams as streams # type: ignore synthesizer = speechsynthesis.SpeechSynthesizer()