69 lines
2.3 KiB
Python
69 lines
2.3 KiB
Python
import os
|
|
import sys
|
|
import shutil
|
|
|
|
def run_diagnostics():
|
|
print("="*50)
|
|
print(" DIAGNOSTICS & SYSTEM CHECKS (OPENAI)")
|
|
print("="*50)
|
|
|
|
# 1. Check Python Dependencies
|
|
print("[1] Checking python imports...")
|
|
deps = ["openai", "dotenv", "tqdm", "requests"]
|
|
for dep in deps:
|
|
try:
|
|
__import__(dep)
|
|
print(f" - {dep}: OK")
|
|
except ImportError:
|
|
print(f" - {dep}: NOT INSTALLED (run: pip install {dep})")
|
|
|
|
# 2. Check FFmpeg
|
|
print("\n[2] Checking FFmpeg...")
|
|
ffmpeg_path = shutil.which("ffmpeg")
|
|
if ffmpeg_path:
|
|
print(f" - FFmpeg found: {ffmpeg_path}")
|
|
else:
|
|
print(" - FFmpeg NOT found in system PATH. Subtitle burning will fail.")
|
|
print(" Install it via: brew install ffmpeg")
|
|
|
|
# 3. Check Configurations
|
|
print("\n[3] Checking configurations & environment...")
|
|
try:
|
|
import config
|
|
print(f" - Config loaded successfully.")
|
|
print(f" - OPENAI_API_KEY: {'Configured' if config.OPENAI_API_KEY else 'Not Configured (Must set in .env)'}")
|
|
print(f" - Default Whisper model: {config.DEFAULT_WHISPER_MODEL}")
|
|
print(f" - Default GPT model: {config.DEFAULT_OPENAI_MODEL}")
|
|
except Exception as e:
|
|
print(f" - Failed to load config: {e}")
|
|
|
|
# 4. Test OpenAI Connection
|
|
print("\n[4] Testing OpenAI Connection...")
|
|
if not config.OPENAI_API_KEY:
|
|
print(" - OpenAI Test: SKIPPED (API Key missing)")
|
|
print("="*50)
|
|
return
|
|
|
|
try:
|
|
from translator import OpenAIAPITranslator
|
|
|
|
translator = OpenAIAPITranslator()
|
|
test_text = "Hello, how are you today?"
|
|
|
|
print(f" - Translating phrase: \"{test_text}\" to Spanish...")
|
|
translated = translator.translate_text(test_text, "en", "es")
|
|
|
|
print(f" - Output: \"{translated}\"")
|
|
if translated != test_text:
|
|
print(" - OpenAI Connection Test: SUCCESS")
|
|
else:
|
|
print(" - OpenAI Connection Test: WARNING (returned original text, check API usage)")
|
|
except Exception as e:
|
|
print(f" - OpenAI Connection Test: FAILED ({e})")
|
|
print(" Please verify your OPENAI_API_KEY in the .env file.")
|
|
|
|
print("\n" + "="*50)
|
|
|
|
if __name__ == "__main__":
|
|
run_diagnostics()
|