!pip install -q kokoro>=0.9.4 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)
# on Ubuntu or Debian
sudo apt update && sudo apt install ffmpeg
# on Arch Linux
sudo pacman -S ffmpeg
# on MacOS using Homebrew (https://brew.sh/)
brew install ffmpeg
# on Windows using Chocolatey (https://chocolatey.org/)
choco install ffmpeg
# on Windows using Scoop (https://scoop.sh/)
scoop install ffmpeg
kokoro vs whisper 常见问题 (FAQ)
kokoro 和 whisper 在开源协议与商用合规上有什么区别?
hexgrad/kokoro 采用 Apache-2.0 · 允许商用(宽松开源协议,允许商业使用、修改与私有化闭源分发(保留版权声明即可)。);openai/whisper 采用 MIT · 允许商用(宽松开源协议,允许商业使用、修改与私有化闭源分发(保留版权声明即可)。)。
2026 年 kokoro 与 whisper 哪个社区增长更快?
按 RepoForAI 实时快照,kokoro 总 Star 10,499(7日 +149),whisper 总 Star 113,882(7日 +530),近期增速由 whisper 领先。