From d0d9897e81f0d23f3dec12359f9d8843fce03937 Mon Sep 17 00:00:00 2001 From: teknium1 Date: Wed, 4 Mar 2026 21:35:04 -0800 Subject: [PATCH] refactor: clean up transcription_tools after PR #262 merge - Fix incorrect error message (only VOICE_TOOLS_OPENAI_KEY is checked, not OPENAI_API_KEY) - Remove redundant FileNotFoundError catch (exists() check above already handles this) - Consolidate openai imports to single line - Sort SUPPORTED_FORMATS in error message for deterministic output --- tools/transcription_tools.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tools/transcription_tools.py b/tools/transcription_tools.py index 1baced60..8e26e094 100644 --- a/tools/transcription_tools.py +++ b/tools/transcription_tools.py @@ -61,7 +61,7 @@ def transcribe_audio(file_path: str, model: Optional[str] = None) -> Dict[str, A return { "success": False, "transcript": "", - "error": "VOICE_TOOLS_OPENAI_KEY or OPENAI_API_KEY not set", + "error": "VOICE_TOOLS_OPENAI_KEY not set", } audio_path = Path(file_path) @@ -86,7 +86,7 @@ def transcribe_audio(file_path: str, model: Optional[str] = None) -> Dict[str, A return { "success": False, "transcript": "", - "error": f"Unsupported file format: {audio_path.suffix}. Supported formats: {', '.join(SUPPORTED_FORMATS)}", + "error": f"Unsupported file format: {audio_path.suffix}. Supported formats: {', '.join(sorted(SUPPORTED_FORMATS))}", } # Validate file size @@ -111,8 +111,7 @@ def transcribe_audio(file_path: str, model: Optional[str] = None) -> Dict[str, A model = DEFAULT_STT_MODEL try: - from openai import OpenAI - from openai import APIError, APIConnectionError, APITimeoutError + from openai import OpenAI, APIError, APIConnectionError, APITimeoutError client = OpenAI(api_key=api_key, base_url="https://api.openai.com/v1") @@ -133,13 +132,6 @@ def transcribe_audio(file_path: str, model: Optional[str] = None) -> Dict[str, A "transcript": transcript_text, } - except FileNotFoundError: - logger.error("Audio file not found: %s", file_path, exc_info=True) - return { - "success": False, - "transcript": "", - "error": f"Audio file not found: {file_path}", - } except PermissionError: logger.error("Permission denied accessing file: %s", file_path, exc_info=True) return {