From eda4c303bad5fb7a6e4429b298858b3dfb8b3cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Wed, 15 May 2024 02:00:20 +0800 Subject: [PATCH] fix --- LunaTranslator/LunaTranslator/gui/showword.py | 8 +++++++- .../LunaTranslator/myutils/ankiconnect_config.py | 2 ++ LunaTranslator/LunaTranslator/tts/basettsclass.py | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/showword.py b/LunaTranslator/LunaTranslator/gui/showword.py index 243053e7..c23d520c 100644 --- a/LunaTranslator/LunaTranslator/gui/showword.py +++ b/LunaTranslator/LunaTranslator/gui/showword.py @@ -119,6 +119,7 @@ class AnkiWindow(QDialog): } ) media = [] + tempfiles=[] for k, _ in [("audio", self.audiofile), ("image", self.cropedimagepath)]: if _: media.append( @@ -130,6 +131,7 @@ class AnkiWindow(QDialog): } ] ) + tempfiles.append(_) else: media.append([]) @@ -145,7 +147,11 @@ class AnkiWindow(QDialog): media[0], media[1], ) - + for _ in tempfiles: + try: + os.remove(_) + except: + pass class searchwordW(closeashidewindow): getnewsentencesignal = pyqtSignal(str, bool) diff --git a/LunaTranslator/LunaTranslator/myutils/ankiconnect_config.py b/LunaTranslator/LunaTranslator/myutils/ankiconnect_config.py index fb43e4a2..1bdd105f 100644 --- a/LunaTranslator/LunaTranslator/myutils/ankiconnect_config.py +++ b/LunaTranslator/LunaTranslator/myutils/ankiconnect_config.py @@ -15,6 +15,7 @@ model_htmlfront = """ {{explain}}
{{image}} +
{{audio}}
""" model_htmlback = """ {{word}} @@ -22,4 +23,5 @@ model_htmlback = """ {{explain}}
{{image}} +
{{audio}}
""" diff --git a/LunaTranslator/LunaTranslator/tts/basettsclass.py b/LunaTranslator/LunaTranslator/tts/basettsclass.py index 9a162e2d..c0b69ef9 100644 --- a/LunaTranslator/LunaTranslator/tts/basettsclass.py +++ b/LunaTranslator/LunaTranslator/tts/basettsclass.py @@ -1,5 +1,5 @@ from myutils.config import globalconfig -import threading +import threading, os class TTSbase: @@ -71,4 +71,4 @@ class TTSbase: voice = globalconfig["reader"][self.typename]["voice"] voice_index = self.voicelist.index(voice) fname = self.speak(content, rate, voice, voice_index) - return fname + return os.path.abspath(fname)