Nodes/comfyui-kokoro/Kokoro Generator
ComfyUI Node

Kokoro Generator

Turn text into speech inside a ComfyUI graph

By stavsap·Created 2 years ago·Updated 6 months ago· 66
Kokoro Generator
  • speaker
  • audio
textI am a synthesized robot
speed1.00
langEnglish

This is the node the other two exist for. Feed it a line of text and a speaker, and it hands you actual audio you can save, play, or bake into a video for lip-sync. It's the payoff in the stavsap/comfyui-kokoro pack - the local TTS engine dressed up as a ComfyUI node, with no API key and no GPU requirement. That combination is the entire appeal: Kokoro-82M is small enough that a CPU synthesizes speech in close to real time.

The README's example workflow is basically three nodes in a row: Kokoro Speaker → Kokoro Generator → save or combine. Everything else is text.

How it works

The node maps the language dropdown to a locale code (English → en-us, English (British) → en-gb, French → fr-fr, and so on), loads the ONNX model, and calls create(text, voice, speed, lang). That returns a waveform plus its sample rate, which the node reshapes into a standard ComfyUI AUDIO value - a waveform tensor and a sample rate. Which means the output plugs into anything that accepts AUDIO: ComfyUI's built-in SaveAudio to write an MP3/WAV, or VideoHelperSuite's VHS_VideoCombine to merge it into a video track for lip-sync, the use case the pack's README leads with.

The model file is the full fp32 kokoro.onnx (325 MB), pulled automatically on first run into the node's folder. The pack doesn't use the smaller quantized builds - a minor miss, but you only pay for it once.

The inputs that matter

Four inputs, one output:

  • text - multiline, default "I am a synthesized robot". Your script.
  • speaker - a KOKORO_SPEAKER from the Kokoro Speaker node. You can't type a voice name here; it must be wired in.
  • speed - float, 0.1 to 4, default 1. Step 0.05. Keep voiceovers near 1; crank past 1.2 and the narrator sounds like they're on a deadline.
  • lang - 9 options: English, English (British), French, Japanese, Hindi, Mandarin Chinese, Spanish, Brazilian Portuguese, Italian.
  • audio - the AUDIO output. Wire to SaveAudio or VHS.

The one real gotcha here: pick the language that matches your voice's prefix. A Japanese voice with the language set to English will sound wrong, and multilingual quality is uneven - Hindi, for instance, is noticeably weaker than English in community reports. If in doubt, stay in your voice's native accent and it'll be at its best.

Installing it

Via ComfyUI Manager (search "Kokoro" by stavsap), or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/stavsap/comfyui-kokoro.git
cd comfyui-kokoro
pip install -r requirements.txt

Then restart ComfyUI. Requirements are kokoro-onnx, onnxruntime, numpy, requests, tqdm. onnxruntime is CPU-friendly, so this runs fine on the same box that does nothing else while your GPU idles.

Troubleshooting

The classic failure: the node returns nothing and the workflow silently produces no audio. It doesn't crash - the code catches errors, logs them to the console, and returns None. So if you queue and get silence, read the terminal before you suspect the speaker. Two causes dominate.

First-run download. Everything downloads lazily inside the nodes - model plus per-voice data - so the first queue can sit on a progress bar for a while. No internet on first run means no model, and the generator just fails quietly. Windows portable users should install requirements into the embedded Python:

cd ComfyUI_windows_portable
python_embeded\python.exe -m pip install -r ComfyUI\custom_nodes\comfyui-kokoro\requirements.txt

Second, the broken speaker wire. If you fed the generator a plain string instead of a KOKORO_SPEAKER, the graph won't even connect - the type is enforced. Long scripts work because the engine chunks text internally, but if you're pushing many paragraphs, splitting per-generation and stitching with ffmpeg keeps each pass fast and debuggable. Past that, this node just works - which is more than most ComfyUI audio setups can claim.

Categorykokoro

Inputs (4)

NameTypeDefaultDescription
textSTRINGI am a synthesized robot
speakerKOKORO_SPEAKER
speedFLOAT1.000.1–4
langCOMBOEnglish9 options: English, English (British), French, Japanese, Hindi, Mandarin Chinese, +3

Outputs (1)

NameTypeDescription
audioAUDIO