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: