From ed073df1bc5f52c1d439578dc6204bac556eb511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paluch?= Date: Tue, 20 Oct 2026 17:49:36 +0200 Subject: [PATCH] =?UTF-8?q?TTS:=20czyste=20=C5=9Brodowisko=20(LD=5FLIBRARY?= =?UTF-8?q?=5FPATH=3D/opt/piper-tts)=20=E2=80=94=20naprawa=20konfliktu=20l?= =?UTF-8?q?ibespeak-ng=20ze=20Steam=20Runtime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PythonPlugins/PI_XSayATC.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/PythonPlugins/PI_XSayATC.py b/PythonPlugins/PI_XSayATC.py index b40a669..b0fe739 100644 --- a/PythonPlugins/PI_XSayATC.py +++ b/PythonPlugins/PI_XSayATC.py @@ -627,6 +627,18 @@ class XSayATC: xp.log(f"[XSayATC] Blad whisper: {e}") return "" + def _clean_env(self): + """Zwraca srodowisko bez LD_LIBRARY_PATH/LD_PRELOAD ze Steam, zeby + piper/pw-play uzywaly wlasnych bibliotek (inaczej Steam Runtime podklada + stara libespeak-ng i piper zwraca pusty plik).""" + env = dict(os.environ) + env.pop("LD_PRELOAD", None) + # Zostawiamy tylko sciezki systemowe, nie Steam Runtime. + ld = env.pop("LD_LIBRARY_PATH", "") + # Dopisujemy /opt/piper-tts na poczatek, by piper znalazl swoje libs. + env["LD_LIBRARY_PATH"] = "/opt/piper-tts" + return env + def _speak(self, text): """Synteza mowy (piper) i odtworzenie. Watek roboczy.""" if not self.config.get("tts_enabled", True): @@ -639,18 +651,20 @@ class XSayATC: model = self.config.get("piper_model", "") import tempfile wav = tempfile.mktemp(suffix=".wav", prefix="xsayatc_tts_") + env = self._clean_env() try: xp.log(f"[XSayATC] TTS: piper -> {wav}") p = subprocess.Popen( [piper, "-m", model, "-f", wav], - stdin=subprocess.PIPE, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE) + stdin=subprocess.PIPE, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, + env=env) _out, err = p.communicate(input=text.encode("utf-8"), timeout=60) if err: xp.log(f"[XSayATC] TTS piper stderr: {err.decode('utf-8', 'ignore')[:200]}") if os.path.exists(wav) and os.path.getsize(wav) > 0: play_cmd = list(self.config.get("play_cmd", ["pw-play"])) xp.log(f"[XSayATC] TTS: odtwarzam: {play_cmd} {wav}") - r = subprocess.run(play_cmd + [wav], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, timeout=60) + r = subprocess.run(play_cmd + [wav], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, timeout=60, env=env) if r.returncode != 0: xp.log(f"[XSayATC] TTS odtwarzanie kod={r.returncode} stderr={r.stderr.decode('utf-8','ignore')[:200]}") try: