This is an adapted version of KokoroSharp that updates the C# 9+ syntax and uses a KokoroWaveOutEvent for Unity audio sources to make it usable in Unity.
This package includes the eSpeak NG dlls from https://github.com/Lyrcaxis/KokoroSharpBinaries, where you can also get the voices by running the download script.
The voices are expected to be in Assets/StreamingAssets/Kokoro/voices.
You can install this package by:
- Opening your Unity project
- Opening the Package Manager (Window > Package Manager)
- Click the "+" button in the top-left
- Select "Add package from git URL..."
- Enter the repository URL:
https://github.com/unipotent/KokoroSharpUnity.git - Click "Add"
This package requires the package com.github.asus4.onnxruntime Be sure to follow the installation instructions from their readme.
- Add voices as mentioned above
- Add the KokoroUnity component to a GameObject, and drag in your audio source.
Example code:
using KokoroSharp;
using KokoroSharp.Core;
void Start()
{
KokoroTTS kokoroTTS = KokoroTTS.LoadModel();
KokoroVoice voice = KokoroVoiceManager.GetVoice("af_heart");
kokoroTTS.SpeakFast("Hello World!", voice);
}Tested on Unity 6, Windows 11 on CPU
- This package is provided under the MIT LICENSE.
- KokoroSharp is licensed under the MIT License.
- The Kokoro 82M model and its voices are released under the Apache License.
- eSpeak NG is licensed under the GPLv3 License.
- NumSharp is licensed under the Apache 2.0 License.
- NAudio is licensed under the MIT Licnese.