#!/usr/bin/env python3 """ Test script for TTS audio streaming. Run this inside the miku-bot container to test audio output. """ import asyncio import sys sys.path.insert(0, '/app') from utils.voice_audio import TTSTokenStreamer async def test(): print("🎤 Testing TTS audio streaming...") try: streamer = TTSTokenStreamer() print("📡 Connecting to TTS WebSocket...") await streamer.connect() print("✓ Connected!") test_text = "Hello, this is a test!" print(f"📤 Sending text: '{test_text}'") words = test_text.split() for word in words: print(f" → Sending: '{word}'") await streamer.send_token(word + " ") await asyncio.sleep(0.1) print("✓ All tokens sent!") print("⏳ Waiting 2 seconds for audio to finish...") await asyncio.sleep(2) await streamer.disconnect() print("✓ Disconnected") print("🎉 Test complete!") except Exception as e: print(f"❌ Error: {e}") import traceback traceback.print_exc() if __name__ == "__main__": asyncio.run(test())