-
Notifications
You must be signed in to change notification settings - Fork 752
Expand file tree
/
Copy pathexample.py
More file actions
27 lines (16 loc) · 874 Bytes
/
example.py
File metadata and controls
27 lines (16 loc) · 874 Bytes
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
from kittentts import KittenTTS
# it will run blazing fast on any GPU. But this example will run on CPU.
# Step 1: Load the model
m = KittenTTS("KittenML/kitten-tts-mini-0.8") # 80M version (highest quality)
# m = KittenTTS("KittenML/kitten-tts-micro-0.8") # 40M version (balances speed and quality )
# m = KittenTTS("KittenML/kitten-tts-nano-0.8") # 15M version (tiny and faster )
# Step 2: Generate the audio
# this is a sample from the TinyStories dataset.
text ="""One day, a little girl named Lily found a needle in her room. She knew it was difficult to play with it because it was sharp. """
# available_voices : ['Bella', 'Jasper', 'Luna', 'Bruno', 'Rosie', 'Hugo', 'Kiki', 'Leo']
voice = 'Bruno'
audio = m.generate(text=text, voice=voice )
# Save the audio
import soundfile as sf
sf.write('output.wav', audio, 24000)
print(f"Audio saved to output.wav")