LocalAI icon indicating copy to clipboard operation
LocalAI copied to clipboard

Add TTS model Kokoro

Open Hello-World-Traveler opened this issue 8 months ago • 2 comments

Is your feature request related to a problem? Please describe. Add another TTS model

Describe the solution you'd like Kokoro is an open-weight TTS model with 82 million parameters. Despite its lightweight architecture, it delivers comparable quality to larger models while being significantly faster and more cost-efficient. With Apache-licensed weights, Kokoro can be deployed anywhere from production environments to personal projects.

https://huggingface.co/hexgrad/Kokoro-82M

sample file: https://huggingface.co/hexgrad/Kokoro-82M/resolve/main/samples/HEARME.wav

!pip install -q kokoro>=0.9.2 soundfile
!apt-get -qq -y install espeak-ng > /dev/null 2>&1
from kokoro import KPipeline
from IPython.display import display, Audio
import soundfile as sf
import torch
pipeline = KPipeline(lang_code='a')
text = '''
[Kokoro](/kˈOkəɹO/) is an open-weight TTS model with 82 million parameters. Despite its lightweight architecture, it delivers comparable quality to larger models while being significantly faster and more cost-efficient. With Apache-licensed weights, [Kokoro](/kˈOkəɹO/) can be deployed anywhere from production environments to personal projects.
'''
generator = pipeline(text, voice='af_heart')
for i, (gs, ps, audio) in enumerate(generator):
    print(i, gs, ps)
    display(Audio(data=audio, rate=24000, autoplay=i==0))
    sf.write(f'{i}.wav', audio, 24000)

Hello-World-Traveler avatar Apr 19 '25 12:04 Hello-World-Traveler

There is already a kokoro backend, however not documented. This needs some spot in our docs

mudler avatar Apr 19 '25 13:04 mudler

And don't forget to add these models to the gallery!

SuperPat45 avatar Apr 20 '25 12:04 SuperPat45

Hi,

First of all, thanks a million for the great project you've been putting together.

I am trying to run Kokoro and Chatterbox using the new Backends gallery, but I am not sure what to do after installing the "cuda12-kokoro-development" for example. Do I have to create a model config file? in which case, what model format should I reference?

Any guidance would be highly appreciated.

GvaraX avatar Jun 22 '25 15:06 GvaraX

As soon as the images are built on master ( https://github.com/mudler/LocalAI/pull/5978 ), the kokoro updated backend will be available, and it should be enough to install it with local-ai run kokoro, or select the kokoro model from the gallery.

mudler avatar Aug 06 '25 13:08 mudler