Skip to content

This is a webui and api project for the kokoro TTS project, supporting voice synthesis in 8 languages: Chinese, English, Japanese, French, Italian, Portuguese, Spanish, and Hindi.

Project URL: https://github.com/jianchang512/kokoro-uiapi

Web Interface

Default UI address after startup: http://127.0.0.1:5066

  • Supports dubbing for text and SRT subtitles
  • Supports online preview and download
  • Supports subtitle alignment

Installation Methods

Windows

For Windows 10/11, you can directly download the integrated package and double-click start.bat to launch. For GPU acceleration, please ensure you have an NVIDIA graphics card and have CUDA 12 installed.

GitHub Download URL: https://github.com/jianchang512/kokoro-uiapi/releases/v0.1

Linux/MacOS

First, ensure your system has Python 3.8+ installed; Python 3.10-3.11 is recommended.

On Linux, pre-install ffmpeg using apt install ffmpeg or yum install ffmpeg.

On MacOS, install ffmpeg using brew install ffmpeg.

  1. Clone the source code: git clone https://github.com/jianchang512/kokoro-uiapi
  2. Create and activate a virtual environment:
    cd kokoro-uiapi
    python3 -m venv venv
    . venv/bin/activate
  3. Install dependencies: pip3 install -r requirements.txt
  4. Start the application: python3 app.py

Using with pyVideoTrans

  1. First, start this project. For the Windows integrated package, double-click start.bat. For source installation, run python3 app.py.
  2. Upgrade pyVideoTrans to v3.48+. Open the menu -- TTS Settings -- Kokoro TTS -- and fill in the HTTP address as http://127.0.0.1:5066.

OpenAI API Compatibility

The API is compatible with OpenAI TTS.

Default API address after startup: http://127.0.0.1:5066/v1/audio/speech

Request Method: POST Request Data: application/json

{
    input: Text to be dubbed,
    voice: Voice role,
    speed: Speech rate, default 1.0
}

Returns MP3 audio data on success.

OpenAI SDK Usage Example

from openai import OpenAI
client = OpenAI(
    api_key='123456',
    base_url='http://127.0.0.1:5066/v1'
)

try:
    response = client.audio.speech.create(
        model='tts-1',
        input='Hello there, dear friends',
        voice='zf_xiaobei',
        response_format='mp3',
        speed=1.0
    )
    with open('./test_openai.mp3', 'wb') as f:
        f.write(response.content)
    print("MP3 file saved successfully to test_openai.mp3")
except Exception as e:
    print(f"An error occurred: {e}")

Voice Role List

English Voice Roles:

af_alloy
af_aoede
af_bella
af_jessica
af_kore
af_nicole
af_nova
af_river
af_sarah
af_sky
am_adam
am_echo
am_eric
am_fenrir
am_liam
am_michael
am_onyx
am_puck
am_santa
bf_alice
bf_emma
bf_isabella
bf_lily
bm_daniel
bm_fable
bm_george
bm_lewis

Chinese Roles:

zf_xiaobei
zf_xiaoni
zf_xiaoxiao
zf_xiaoyi
zm_yunjian
zm_yunxi
zm_yunxia
zm_yunyang

Japanese Roles:

jf_alpha
jf_gongitsune
jf_nezumi
jf_tebukuro
jm_kumo

French Role: ff_siwis

Italian Roles: if_sara, im_nicola

Hindi Roles: hf_alpha, hf_beta, hm_omega, hm_psi

Spanish Roles: ef_dora, em_alex, em_santa

Portuguese Roles: pf_dora, pm_alex, pm_santa

Proxy/VPN

For source code deployment, voice model .pt files need to be downloaded from huggingface.co. Please set up a global proxy or system proxy in advance to ensure access.

Alternatively, you can download the model in advance and extract it to the directory where app.py is located.

Model Download URL: https://github.com/jianchang512/kokoro-uiapi/releases/download/v0.1/moxing--jieya--dao--app.py--mulu.7z

Credit