From 862d5378eb2d7755581b1521f254c050bf7faebf 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: Tue, 27 Aug 2024 15:14:01 +0800 Subject: [PATCH] check --- LunaTranslator/LunaTranslator/gui/showword.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/showword.py b/LunaTranslator/LunaTranslator/gui/showword.py index 36d2cd95..75029517 100644 --- a/LunaTranslator/LunaTranslator/gui/showword.py +++ b/LunaTranslator/LunaTranslator/gui/showword.py @@ -47,23 +47,32 @@ class AnkiWindow(QWidget): __ocrsettext = pyqtSignal(str) refreshhtml = pyqtSignal() - def callbacktts(self, edit, data): + def callbacktts(self, edit, sig, data): + if sig != edit.sig: + return fname = gobject.gettempdir(str(uuid.uuid4()) + ".mp3") with open(fname, "wb") as ff: ff.write(data) edit.setText(os.path.abspath(fname)) def langdu(self): + self.audiopath.sig = uuid.uuid4() if gobject.baseobject.reader: gobject.baseobject.reader.ttscallback( - self.currentword, functools.partial(self.callbacktts, self.audiopath) + self.currentword, + functools.partial(self.callbacktts, self.audiopath, self.audiopath.sig), ) def langdu2(self): + self.audiopath_sentence.sig = uuid.uuid4() if gobject.baseobject.reader: gobject.baseobject.reader.ttscallback( self.example.toPlainText(), - functools.partial(self.callbacktts, self.audiopath_sentence), + functools.partial( + self.callbacktts, + self.audiopath_sentence, + self.audiopath_sentence.sig, + ), ) @threader