From 106e00c826b6c01a6366cceebcc8af8bf55f5591 Mon Sep 17 00:00:00 2001 From: Raivis Dejus Date: Fri, 17 Oct 2025 07:19:38 +0300 Subject: [PATCH] Fix for whisper executable path in frozen envs --- buzz/transcriber/recording_transcriber.py | 4 +--- buzz/transcriber/whisper_cpp.py | 13 ++++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/buzz/transcriber/recording_transcriber.py b/buzz/transcriber/recording_transcriber.py index 539edaa2..950114d0 100644 --- a/buzz/transcriber/recording_transcriber.py +++ b/buzz/transcriber/recording_transcriber.py @@ -333,10 +333,8 @@ class RecordingTranscriber(QObject): self.process = None - # Get the directory where whisper-server is located - script_dir = os.path.dirname(os.path.abspath(__file__)) server_executable = "whisper-server.exe" if sys.platform == "win32" else "whisper-server" - server_path = os.path.join(script_dir, "..", "whisper_cpp", server_executable) + server_path = os.path.join(APP_BASE_DIR, "whisper_cpp", server_executable) cmd = [ server_path, diff --git a/buzz/transcriber/whisper_cpp.py b/buzz/transcriber/whisper_cpp.py index 3e8ae810..e78601d7 100644 --- a/buzz/transcriber/whisper_cpp.py +++ b/buzz/transcriber/whisper_cpp.py @@ -6,6 +6,7 @@ import subprocess import json import tempfile from typing import List +from buzz.assets import APP_BASE_DIR from buzz.transcriber.transcriber import Segment, Task, FileTranscriptionTask from buzz.transcriber.file_transcriber import app_env @@ -36,10 +37,8 @@ class WhisperCpp: @staticmethod def transcribe(task: FileTranscriptionTask) -> List[Segment]: """Transcribe audio using whisper-cli subprocess.""" - # Get the directory where whisper-cli is located - script_dir = os.path.dirname(os.path.abspath(__file__)) cli_executable = "whisper-cli.exe" if sys.platform == "win32" else "whisper-cli" - whisper_cli_path = os.path.join(script_dir, "..", "whisper_cpp", cli_executable) + whisper_cli_path = os.path.join(APP_BASE_DIR, "whisper_cpp", cli_executable) language = ( task.transcription_options.language @@ -113,7 +112,7 @@ class WhisperCpp: if force_cpu != "false" or not IS_VULKAN_SUPPORTED: cmd.append("--no-gpu") - logging.debug(f"Running Whisper CLI: {' '.join(cmd)}") + print(f"Running Whisper CLI: {' '.join(cmd)}") # Run the whisper-cli process if sys.platform == "win32": @@ -155,7 +154,7 @@ class WhisperCpp: try: os.remove(temp_file) except Exception as e: - logging.warning(f"Failed to remove temporary file {temp_file}: {e}") + print(f"Failed to remove temporary file {temp_file}: {e}") raise Exception(f"whisper-cli failed with return code {process.returncode}") # Find and read the generated JSON file @@ -277,11 +276,11 @@ class WhisperCpp: try: os.remove(json_output_path) except Exception as e: - logging.warning(f"Failed to remove JSON output file {json_output_path}: {e}") + print(f"Failed to remove JSON output file {json_output_path}: {e}") # Clean up temporary audio file if conversion was done if temp_file and os.path.exists(temp_file): try: os.remove(temp_file) except Exception as e: - logging.warning(f"Failed to remove temporary file {temp_file}: {e}") \ No newline at end of file + print(f"Failed to remove temporary file {temp_file}: {e}") \ No newline at end of file