#!/usr/bin/env python3
"""Generate test audio WAV file for STT testing"""

import sys

try:
    from gtts import gTTS
    import os
    from pydub import AudioSegment

    # Generate French test audio
    text = "Bonjour, ceci est un test de reconnaissance vocale."
    print(f"Generating audio: '{text}'")

    # Create TTS
    tts = gTTS(text=text, lang='fr', slow=False)
    tts.save("test_audio_temp.mp3")
    print("✓ Generated MP3")

    # Convert to WAV (16kHz, mono, 16-bit PCM)
    audio = AudioSegment.from_mp3("test_audio_temp.mp3")
    audio = audio.set_frame_rate(16000).set_channels(1).set_sample_width(2)
    audio.export("test_audio.wav", format="wav")
    print("✓ Converted to WAV (16kHz, mono, 16-bit)")

    # Cleanup
    os.remove("test_audio_temp.mp3")
    print("✓ Saved as test_audio.wav")
    print(f"Duration: {len(audio)/1000:.1f}s")

except ImportError as e:
    print(f"Missing dependency: {e}")
    print("\nInstall with: pip install gtts pydub")
    print("Note: pydub also requires ffmpeg")
    sys.exit(1)
