File size: 2,204 Bytes
b388a4a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
"""

Test script for KittenTTS functionality

"""

import soundfile as sf
import numpy as np
from kittentts import KittenTTS

def test_kittentts():
    """Test the KittenTTS model with a simple example"""
    
    print("πŸš€ Testing KittenTTS...")
    
    try:
        # Initialize the model
        print("πŸ“¦ Loading KittenTTS model...")
        model = KittenTTS("KittenML/kitten-tts-nano-0.1")
        print("βœ… Model loaded successfully!")
        
        # Test text
        test_text = "Hello! This is a test of the KittenTTS model."
        test_voice = 'expr-voice-2-f'
        
        print(f"🎀 Generating speech for: '{test_text}'")
        print(f"🎡 Using voice: {test_voice}")
        
        # Generate audio
        audio = model.generate(test_text, voice=test_voice)
        
        print(f"βœ… Audio generated successfully!")
        print(f"πŸ“Š Audio shape: {audio.shape}")
        print(f"πŸ“Š Audio dtype: {audio.dtype}")
        print(f"πŸ“Š Audio range: {np.min(audio):.4f} to {np.max(audio):.4f}")
        
        # Save test audio
        output_file = 'test_output.wav'
        sf.write(output_file, audio, 24000)
        print(f"πŸ’Ύ Audio saved to: {output_file}")
        
        # Test all voices
        print("\n🎭 Testing all available voices...")
        available_voices = [
            'expr-voice-2-m', 'expr-voice-2-f', 'expr-voice-3-m', 'expr-voice-3-f',
            'expr-voice-4-m', 'expr-voice-4-f', 'expr-voice-5-m', 'expr-voice-5-f'
        ]
        
        for i, voice in enumerate(available_voices, 1):
            print(f"  {i}/8: Testing {voice}...")
            try:
                test_audio = model.generate("Test voice.", voice=voice)
                print(f"    βœ… {voice} works!")
            except Exception as e:
                print(f"    ❌ {voice} failed: {e}")
        
        print("\nπŸŽ‰ All tests completed successfully!")
        return True
        
    except Exception as e:
        print(f"❌ Test failed: {e}")
        return False

if __name__ == "__main__":
    success = test_kittentts()
    exit(0 if success else 1)