File size: 1,487 Bytes
f05f9c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
Quick test script for Kokoro-82M TTS integration via HF Inference API
"""
import asyncio
import logging
from agents.audio_agent import AudioAgent

logging.basicConfig(level=logging.INFO)

async def test_kokoro():
    """Test Kokoro-82M audio generation via HF API"""
    print("🎀 Testing Kokoro-82M Integration (HF Inference API)...\n")
    
    agent = AudioAgent()
    
    test_text = """
    Welcome to Science Storyteller! This is a test of our Kokoro-82M integration.
    Kokoro is an open-source, Apache-licensed TTS model with 82 million parameters.
    It delivers high-quality, natural-sounding speech that's perfect for podcasts.
    Let's hear how it sounds!
    """
    
    print(f"Model: hexgrad/Kokoro-82M")
    print(f"Text length: {len(test_text)} characters\n")
    
    print("Generating audio with Kokoro-82M via HF Inference API...")
    audio_path = await agent.text_to_speech(test_text, "test_kokoro.wav")
    
    if audio_path:
        print(f"\nβœ… SUCCESS! Audio saved to: {audio_path}")
        
        # Check file size
        from pathlib import Path
        file_size = Path(audio_path).stat().st_size / 1024  # KB
        print(f"πŸ“¦ File size: {file_size:.2f} KB")
        
        print("\n🎧 You can play the audio file to verify quality!")
        return True
    else:
        print("\n❌ FAILED to generate audio")
        return False

if __name__ == "__main__":
    success = asyncio.run(test_kokoro())
    exit(0 if success else 1)