File size: 756 Bytes
1337d7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import soundfile as sf

from models import Tokenizer, Kokoro


def main():
    model_path = "weights/kokoro-v0_19.onnx"
    style_vector_path = "voices/af.pt"
    output_filename = "test_out.wav"
    tokenizer = Tokenizer()

    text = (
        "This approach ensures the entire text is processed without exceeding the token limit and outputs seamless audio for the full input. Let me know if you need further assistance!"
    )

    inference = Kokoro(model_path, style_vector_path, tokenizer=tokenizer, lang='en-us')
    audio, sample_rate = inference.generate_audio(text, speed=1.0)

    # Save the audio to a file
    sf.write(output_filename, audio, sample_rate)
    print(f"Audio saved to {output_filename}")


if __name__ == "__main__":
    main()