#!/usr/bin/env python3
import subprocess
import time
import sys

cmd = [
    "/opt/homebrew/bin/python3.11",
    "scripts/asr_processor_debug.py",
    "../test_video/1636719d-c31f-78ac-f1dd-8ab0b0b36c66.mov",
    "/tmp/test_output.json",
    "--uuid",
    "test",
]

print("Running with 5-second timeout...")
start = time.time()
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)

try:
    stdout, stderr = proc.communicate(timeout=5)
    print(f"Completed in {time.time() - start:.1f}s")
except subprocess.TimeoutExpired:
    print(f"Timed out after {time.time() - start:.1f}s")
    proc.kill()
    stdout, stderr = proc.communicate()

print("\n=== STDERR (last 1000 chars) ===")
print(stderr[-1000:] if stderr else "")
