AI Personal Learning
and practical guidance

Kokoro:高效语音合成模型,生成自然流畅的语音

General Introduction

Kokoro 82M 是由 Hugging Face 提供的一个高效语音合成模型,旨在通过较少的参数和数据生成高质量的语音。该模型拥有 8200 万参数,使用 Apache 2.0 许可证发布,支持多种语音包(Voicepacks),可以生成不同风格和语言的语音。Kokoro-82M 在 TTS(Text-to-Speech)领域表现出色,尤其在 Elo 排名中表现优异,能够在较少的计算资源下实现高质量的语音合成。

Kokoro 封装的API:Kokoro TTS API: Dockerized FastAPI wrapper for fast text-to-speech (Kokoro-82M model)


Kokoro:高效语音合成模型,生成自然流畅的语音-1

体验地址:https://huggingface.co/spaces/hexgrad/Kokoro-TTS

 

Function List

  • speech synthesis:生成自然流畅的语音输出。
  • 多语音包支持:提供多种语音包,用户可以选择不同的声音风格。
  • 高效模型:使用较少的参数和数据实现高质量的语音合成。
  • 开源许可:采用 Apache 2.0 许可证,允许自由使用和修改。
  • Community Support:提供 Discord 服务器,用户可以在社区中讨论和反馈。

 

Using Help

Installation process

  1. Installation of dependencies::
   git lfs install
git clone https://huggingface.co/hexgrad/Kokoro-82M
cd Kokoro-82M
apt-get -qq -y install espeak-ng > /dev/null 2>&1
pip install -q phonemizer torch transformers scipy munch
  1. 构建模型并加载默认语音包::
   from models import build_model
import torch
device = 'cuda' if torch.cuda.is_available() else 'cpu'
MODEL = build_model('kokoro-v0_19.pth', device)
VOICE_NAME = 'af'  # 默认语音包
VOICEPACK = torch.load(f'voices/{VOICE_NAME}.pt', weights_only=True).to(device)
print(f'Loaded voice: {VOICE_NAME}')
  1. Generate Speech::
   from kokoro import generate
text = "How could I know? It's an unanswerable question. Like asking an unborn child if they'll lead a good life. They haven't even been born."
audio, out_ps = generate(MODEL, text, VOICEPACK, lang=VOICE_NAME[0])
from IPython.display import display, Audio
display(Audio(data=audio, rate=24000, autoplay=True))

Instructions for use

  1. 选择语音包:Kokoro-82M 提供多种语音包,用户可以根据需要选择不同的声音风格。默认语音包为 af,可以在 voices 文件夹中找到其他语音包。
  2. Generate Speech: Use generate 函数输入文本并生成语音。生成的语音为 24kHz,可以通过 IPython 显示播放。
  3. Adjustment parameters:用户可以根据需要调整模型参数和语音包,以获得最佳的语音合成效果。
May not be reproduced without permission:Chief AI Sharing Circle " Kokoro:高效语音合成模型,生成自然流畅的语音

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish