From 82bf1feaa6bad2b7e7b2c0881332b0419e2073b8 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: Sat, 25 May 2024 00:42:49 +0800 Subject: [PATCH] repair --- LunaTranslator/LunaTranslator/gui/textbrowser.py | 6 +++--- LunaTranslator/LunaTranslator/gui/translatorUI.py | 4 ++-- LunaTranslator/LunaTranslator/tts/edgetts.py | 7 +++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/textbrowser.py b/LunaTranslator/LunaTranslator/gui/textbrowser.py index eef5bff4..c7fb090a 100644 --- a/LunaTranslator/LunaTranslator/gui/textbrowser.py +++ b/LunaTranslator/LunaTranslator/gui/textbrowser.py @@ -506,11 +506,11 @@ class Textbrowser(QLabel): tl1.x() + 1, tl1.y(), tailx - tl1.x() - 2, - heigth, + int(heigth), ) xx = int(guesswidth1 - (tailx - tl1.x())) guesslinehead = None - pos2 = tl3.x() + 1 - xx, tl3.y(), xx - 2, heigth + pos2 = tl3.x() + 1 - xx, tl3.y(), xx - 2, int(heigth) if ( globalconfig["usesearchword"] or globalconfig["usecopyword"] @@ -559,7 +559,7 @@ class Textbrowser(QLabel): tl1.x() + 1, tl1.y(), tl2.x() - tl1.x() - 2, - heigth, + int(heigth), ) if ( globalconfig["usesearchword"] diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index 47e656ca..4ed626c7 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -954,7 +954,7 @@ class QUnFrameWindow(resizableframeless): wh = globalconfig["buttonsize"] * 1.5 height = self.height() - wh - self.translate_text.resize(self.width(), height) + self.translate_text.resize(self.width(), int(height)) self.adjustbuttons() self._TitleLabel.setFixedWidth(self.width()) @@ -1000,7 +1000,7 @@ class QUnFrameWindow(resizableframeless): sumwidth += button.width() leftstart = leftmax + (rightmax - leftmax - sumwidth) / 2 for button in center: - button.move(leftstart, 0) + button.move(int(leftstart), 0) leftstart += button.width() def callwrap(self, call, _): diff --git a/LunaTranslator/LunaTranslator/tts/edgetts.py b/LunaTranslator/LunaTranslator/tts/edgetts.py index a506a90a..2c389a5f 100644 --- a/LunaTranslator/LunaTranslator/tts/edgetts.py +++ b/LunaTranslator/LunaTranslator/tts/edgetts.py @@ -186,10 +186,13 @@ def transferMsTTSData(rate, content, voice): # Extract binary data try: needle = b"Path:audio\r\n" - start_ind = response.find(needle) + len(needle) + idx = response.find(needle) + if idx == -1: + raise + start_ind = idx + len(needle) audio_stream += response[start_ind:] except: - pass + audio_stream += response else: break ws.close()