import soundfile as sf
from pathlib import Path
import sys

p = Path('/opt/ai-avatar-demo/data/tts_outputs/yuka_intro_mandy_clone_gate7m_a_r3.wav')
print('exists=', p.exists())
print('size=', p.stat().st_size if p.exists() else 'NA')
if not p.exists():
    print("ERROR: BLOCKED_OUTPUT_NOT_FOUND!")
    sys.exit(1)

try:
    info = sf.info(str(p))
    print('samplerate=', info.samplerate)
    print('channels=', info.channels)
    print('frames=', info.frames)
    print('duration_sec=', round(info.frames/info.samplerate, 3) if info.samplerate else 'NA')
    print('format=', info.format)
    print('subtype=', info.subtype)
    if p.stat().st_size <= 0:
        print("ERROR: BLOCKED_OUTPUT_EMPTY!")
        sys.exit(1)
except Exception as e:
    print("ERROR:", repr(e))
    sys.exit(1)
