""" Simple local test for Science Storyteller Run this to verify the app works before deploying to HF Spaces """ import asyncio import sys from pathlib import Path # Add parent directory to path sys.path.insert(0, str(Path(__file__).parent)) from agents.audio_agent import AudioAgent async def quick_test(): """Quick test of Kokoro-82M TTS""" print("\nšŸŽ¤ Testing Kokoro-82M TTS Integration...") print("=" * 60) agent = AudioAgent() test_text = """ Welcome to Science Storyteller! This AI-powered system transforms complex research papers into accessible audio podcasts. Let's make science engaging! """ print(f"\nšŸ“ Text: {test_text.strip()}") print(f"šŸ”§ Model: {agent.model}") print(f"šŸ”‘ Token: {agent.hf_token[:10]}...{agent.hf_token[-5:] if agent.hf_token else 'NOT SET'}") print("\nā³ Generating audio...\n") audio_path = await agent.text_to_speech(test_text, "quick_test.wav") if audio_path: file_size = Path(audio_path).stat().st_size / 1024 print(f"\nāœ… SUCCESS!") print(f"šŸ“ File: {audio_path}") print(f"šŸ“¦ Size: {file_size:.2f} KB") print("\nšŸŽ§ Play the audio file to verify quality!") return True else: print("\nāŒ FAILED to generate audio") return False if __name__ == "__main__": try: success = asyncio.run(quick_test()) sys.exit(0 if success else 1) except Exception as e: print(f"\nāŒ Error: {e}") import traceback traceback.print_exc() sys.exit(1)