Files
momentry_core/test_debug.py
Warren b54c2def30 feat: add migrations, test scripts, and utility tools
- Add database migrations (006-028) for face recognition, identity, file_uuid
- Add test scripts for ASR, face, search, processing
- Add portal frontend (Tauri)
- Add config, benchmark, and monitoring utilities
- Add model checkpoints and pretrained model references
2026-04-30 15:11:53 +08:00

89 lines
2.2 KiB
Python

#!/usr/bin/env python3
"""Debug test for ASR processor on large file."""
import subprocess
import sys
import os
import threading
import time
def read_stream(stream, prefix):
"""Read lines from stream and print with prefix."""
for line in iter(stream.readline, ""):
print(f"{prefix}: {line.rstrip()}")
stream.close()
def main():
video_path = "/Users/accusys/test_video/1636719d-c31f-78ac-f1dd-8ab0b0b36c66.mov"
output_path = "/tmp/debug_output.json"
cmd = [
"/opt/homebrew/bin/python3.11",
"scripts/asr_processor.py",
video_path,
output_path,
# No uuid to avoid Redis connection
]
print(f"Running: {' '.join(cmd)}")
print(f"Video size: {os.path.getsize(video_path) / (1024**3):.2f} GB")
# Start process
proc = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
bufsize=1,
universal_newlines=True,
)
# Start threads to read output
stdout_thread = threading.Thread(target=read_stream, args=(proc.stdout, "STDOUT"))
stderr_thread = threading.Thread(target=read_stream, args=(proc.stderr, "STDERR"))
stdout_thread.daemon = True
stderr_thread.daemon = True
stdout_thread.start()
stderr_thread.start()
# Wait with timeout
timeout = 30 # seconds
start = time.time()
try:
while time.time() - start < timeout:
if proc.poll() is not None:
break
time.sleep(0.1)
else:
print(f"\nTimeout after {timeout}s, killing process...")
proc.kill()
proc.wait()
print("Process killed.")
return 1
except KeyboardInterrupt:
proc.kill()
proc.wait()
return 1
# Wait for threads to finish reading remaining output
time.sleep(0.5)
print(f"\nProcess exited with code {proc.returncode}")
if os.path.exists(output_path):
print(f"Output written to {output_path}")
import json
with open(output_path, "r") as f:
data = json.load(f)
print(f"Segments: {len(data.get('segments', []))}")
else:
print("No output file created.")
return 0
if __name__ == "__main__":
sys.exit(main())