From 24e6076b40f1d9b87b9f605b042df6b0271ed91c Mon Sep 17 00:00:00 2001 From: GenericMale Date: Fri, 13 Sep 2024 19:10:52 +0200 Subject: [PATCH] fix: use sys.executable for subprocess calls --- script.py | 6 +++--- tts_server.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/script.py b/script.py index 704e7ba..8b3ce4a 100644 --- a/script.py +++ b/script.py @@ -214,7 +214,7 @@ def run_firsttime_script(): else: script_path = os.path.join(this_dir, 'system', 'config', 'firstrun.py') # Default to Standalone if nothing matched. - subprocess.run(['python', script_path], check=True) + subprocess.run([sys.executable, script_path], check=True) except subprocess.CalledProcessError as e: print(f"Error occurred while running the script: {e}") except Exception as e: @@ -356,7 +356,7 @@ if os.path.isfile("/.dockerenv") and 'google.colab' not in sys.modules: print(f"[{branding}TTS] Internal Gradio address: http://localhost:{params['gradio_port_number']}") # Start the subprocess (now unified for both Docker and non-Docker environments) -process = subprocess.Popen(["python", script_path]) +process = subprocess.Popen([sys.executable, script_path]) # Check if the subprocess has started successfully if process.poll() is None: @@ -468,7 +468,7 @@ check_espeak_ng() def start_subprocess(): global process if process is None or process.poll() is not None: - process = subprocess.Popen(["python", script_path]) + process = subprocess.Popen([sys.executable, script_path]) return "Subprocess started." else: return "Subprocess is already running." diff --git a/tts_server.py b/tts_server.py index 4f3d0ac..fe28966 100644 --- a/tts_server.py +++ b/tts_server.py @@ -1594,7 +1594,7 @@ async def apifunction_trigger_analysis(threshold: int = Query(default=98)): env["PATH"] = os.path.join(venv_path, "bin") + ":" + env["PATH"] ttslist_path = this_dir / output_directory / "ttsList.json" wavfile_path = this_dir / output_directory - subprocess.run(["python", "tts_diff.py", f"--threshold={threshold}", f"--ttslistpath={ttslist_path}", f"--wavfilespath={wavfile_path}"], cwd=this_dir / "system" / "tts_diff", env=env) + subprocess.run([sys.executable, "tts_diff.py", f"--threshold={threshold}", f"--ttslistpath={ttslist_path}", f"--wavfilespath={wavfile_path}"], cwd=this_dir / "system" / "tts_diff", env=env) # Read the analysis summary try: with open(this_dir / output_directory / "analysis_summary.json", "r") as summary_file: @@ -1613,7 +1613,7 @@ async def apifunction_srt_generation(): env["PATH"] = os.path.join(venv_path, "bin") + ":" + env["PATH"] ttslist_path = this_dir / output_directory / "ttsList.json" wavfile_path = this_dir / output_directory - subprocess.run(["python", "tts_srt.py", f"--ttslistpath={ttslist_path}", f"--wavfilespath={wavfile_path}"], cwd=this_dir / "system" / "tts_srt", env=env) + subprocess.run([sys.executable, "tts_srt.py", f"--ttslistpath={ttslist_path}", f"--wavfilespath={wavfile_path}"], cwd=this_dir / "system" / "tts_srt", env=env) srt_file_path = this_dir / output_directory / "subtitles.srt" if not srt_file_path.exists(): raise HTTPException(status_code=404, detail="Subtitle file not found.")