Quickstart with KokoroSharp.CPU
mainTo perform basic text-to-speech synthesis using the CPU package, follow these steps:
- Load the model using
KokoroTTS.LoadModel(). This will automatically download the model (~320MB) if it is not present. - Retrieve a voice using
KokoroVoiceManager.GetVoice(string voiceName). - Use
tts.SpeakFast(string text, KokoroVoice voice)to synthesize and play the text.
Language detection is automated based on the capabilities of the selected voice.
KokoroTTS tts = KokoroTTS.LoadModel(); // Load or download the model
KokoroVoice heartVoice = KokoroVoiceManager.GetVoice("af_heart");
// Speak text from console input
while (true)
{
string input = Console.ReadLine();
tts.SpeakFast(input, heartVoice);
}