Vishwas1 commited on
Commit
b388a4a
Β·
verified Β·
1 Parent(s): 8508174

Upload test_app.py

Browse files
Files changed (1) hide show
  1. test_app.py +65 -0
test_app.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Test script for KittenTTS functionality
4
+ """
5
+
6
+ import soundfile as sf
7
+ import numpy as np
8
+ from kittentts import KittenTTS
9
+
10
+ def test_kittentts():
11
+ """Test the KittenTTS model with a simple example"""
12
+
13
+ print("πŸš€ Testing KittenTTS...")
14
+
15
+ try:
16
+ # Initialize the model
17
+ print("πŸ“¦ Loading KittenTTS model...")
18
+ model = KittenTTS("KittenML/kitten-tts-nano-0.1")
19
+ print("βœ… Model loaded successfully!")
20
+
21
+ # Test text
22
+ test_text = "Hello! This is a test of the KittenTTS model."
23
+ test_voice = 'expr-voice-2-f'
24
+
25
+ print(f"🎀 Generating speech for: '{test_text}'")
26
+ print(f"🎡 Using voice: {test_voice}")
27
+
28
+ # Generate audio
29
+ audio = model.generate(test_text, voice=test_voice)
30
+
31
+ print(f"βœ… Audio generated successfully!")
32
+ print(f"πŸ“Š Audio shape: {audio.shape}")
33
+ print(f"πŸ“Š Audio dtype: {audio.dtype}")
34
+ print(f"πŸ“Š Audio range: {np.min(audio):.4f} to {np.max(audio):.4f}")
35
+
36
+ # Save test audio
37
+ output_file = 'test_output.wav'
38
+ sf.write(output_file, audio, 24000)
39
+ print(f"πŸ’Ύ Audio saved to: {output_file}")
40
+
41
+ # Test all voices
42
+ print("\n🎭 Testing all available voices...")
43
+ available_voices = [
44
+ 'expr-voice-2-m', 'expr-voice-2-f', 'expr-voice-3-m', 'expr-voice-3-f',
45
+ 'expr-voice-4-m', 'expr-voice-4-f', 'expr-voice-5-m', 'expr-voice-5-f'
46
+ ]
47
+
48
+ for i, voice in enumerate(available_voices, 1):
49
+ print(f" {i}/8: Testing {voice}...")
50
+ try:
51
+ test_audio = model.generate("Test voice.", voice=voice)
52
+ print(f" βœ… {voice} works!")
53
+ except Exception as e:
54
+ print(f" ❌ {voice} failed: {e}")
55
+
56
+ print("\nπŸŽ‰ All tests completed successfully!")
57
+ return True
58
+
59
+ except Exception as e:
60
+ print(f"❌ Test failed: {e}")
61
+ return False
62
+
63
+ if __name__ == "__main__":
64
+ success = test_kittentts()
65
+ exit(0 if success else 1)