From 2bfe33a740802b115c7c3bc6ab930880e0d1641c Mon Sep 17 00:00:00 2001 From: Abdo Date: Wed, 4 Jun 2025 17:53:05 +0300 Subject: [PATCH] Fix absolute TTS file paths not working --- qt/aqt/sound.py | 4 ++++ qt/aqt/tts.py | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/qt/aqt/sound.py b/qt/aqt/sound.py index c5d1649e8..84bc71951 100644 --- a/qt/aqt/sound.py +++ b/qt/aqt/sound.py @@ -189,6 +189,10 @@ class AVPlayer: self._enqueued.insert(0, SoundOrVideoTag(filename=os.path.basename(filename))) self._play_next_if_idle() + def insert_tag(self, tag: AVTag) -> None: + self._enqueued.insert(0, tag) + self._play_next_if_idle() + def toggle_pause(self) -> None: if self.current_player: self.current_player.toggle_pause() diff --git a/qt/aqt/tts.py b/qt/aqt/tts.py index 079a5e3de..8926ca0b4 100644 --- a/qt/aqt/tts.py +++ b/qt/aqt/tts.py @@ -41,7 +41,7 @@ import anki.template import aqt from anki import hooks from anki.collection import TtsVoice as BackendVoice -from anki.sound import AVTag, TTSTag +from anki.sound import AVTag, SoundOrVideoTag, TTSTag from anki.utils import checksum, is_win, tmpdir from aqt import gui_hooks from aqt.sound import OnDoneCallback, SimpleProcessPlayer @@ -260,7 +260,7 @@ class MacTTSFilePlayer(MacTTSPlayer): from aqt.sound import av_player av_player.current_player = None - av_player.insert_file(self.tmppath) + av_player.insert_tag(SoundOrVideoTag(filename=self.tmppath)) # Windows support @@ -617,4 +617,4 @@ if is_win: from aqt.sound import av_player av_player.current_player = None - av_player.insert_file(self.tmppath) + av_player.insert_tag(SoundOrVideoTag(filename=self.tmppath))