Make RT import statement conditional, fix formatting, ignore WinRT for type checking

This commit is contained in:
Ryan Aird 2020-12-20 19:43:09 -06:00
parent ac78698a1e
commit a30064d5e9
2 changed files with 6 additions and 4 deletions

View File

@ -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))

View File

@ -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()