import soundfile as sf
import sys

p = '/opt/ai-avatar-demo/data/voice_refs/raw/mandy0526.wav'
try:
    info = sf.info(p)
    duration = info.frames / info.samplerate
    print('samplerate=', info.samplerate)
    print('channels=', info.channels)
    print('frames=', info.frames)
    print('duration_sec=', round(duration, 3) if info.samplerate else 'NA')
    print('format=', info.format)
    print('subtype=', info.subtype)
    if info.channels != 1:
        print("ERROR: BLOCKED_REF_AUDIO_NOT_MONO!")
        sys.exit(1)
    if not (3.0 <= duration <= 30.0):
        print("ERROR: BLOCKED_REF_AUDIO_DURATION_OUT_OF_RANGE!")
        sys.exit(1)
except Exception as e:
    print("ERROR:", repr(e))
    sys.exit(1)
