mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
catch TTS runtime error
This commit is contained in:
parent
402921dac7
commit
4d373f4aa3
1 changed files with 7 additions and 1 deletions
|
@ -41,6 +41,7 @@ from anki.sound import AVTag, TTSTag
|
||||||
from anki.utils import checksum, isWin, tmpdir
|
from anki.utils import checksum, isWin, tmpdir
|
||||||
from aqt import gui_hooks
|
from aqt import gui_hooks
|
||||||
from aqt.sound import OnDoneCallback, SimpleProcessPlayer
|
from aqt.sound import OnDoneCallback, SimpleProcessPlayer
|
||||||
|
from aqt.utils import tooltip
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
@ -565,7 +566,12 @@ if isWin:
|
||||||
asyncio.run(self.speakText(tag, voice.id))
|
asyncio.run(self.speakText(tag, voice.id))
|
||||||
|
|
||||||
def _on_done(self, ret: Future, cb: OnDoneCallback) -> None:
|
def _on_done(self, ret: Future, cb: OnDoneCallback) -> None:
|
||||||
|
try:
|
||||||
ret.result()
|
ret.result()
|
||||||
|
except RuntimeError:
|
||||||
|
# fixme: i18n if this turns out to happen frequently
|
||||||
|
tooltip("TTS failed to play. Please check available languages in system settings.")
|
||||||
|
return
|
||||||
|
|
||||||
# inject file into the top of the audio queue
|
# inject file into the top of the audio queue
|
||||||
from aqt.sound import av_player
|
from aqt.sound import av_player
|
||||||
|
|
Loading…
Reference in a new issue