ComfyUI Node

Kokoro Run

Near-real-time text-to-speech, right in your ComfyUI graph

By billwuhao·Created 2 years ago·Updated about a year ago· 33
Kokoro Run
    • audio
    voicezm_yunyang.pt
    text
    unload_modeltrue
    enable_dialoguefalse
    voice_s2zf_xiaobei.pt

    ComfyUI is mostly about pixels, but every now and then you want a voice - a narration track, a character line for a video, a quick voiceover for a clip you're about to render. KokoroRun is the one node in the ComfyUI_KokoroTTS_MW pack that turns plain text into spoken audio locally, at near-real-time speed, using the Kokoro-82M model. No API, no key, no cloud. You type (or wire in) a sentence, out comes a 24 kHz AUDIO tensor you can preview, save as MP3, or splice into a video workflow.

    Kokoro earned its reputation as one of the best small open TTS models around - it's fast enough on a modest GPU that "near real-time" isn't marketing fluff, and the license is permissive enough that a whole family of ComfyUI wrappers sprang up around it. This one is the PyTorch-flavored variant (a sibling pack, ComfyUI-BS_Kokoro-onnx, does the same job via ONNX). Which you pick mostly comes down to install taste.

    How it works

    Under the hood it's a thin wrapper around the kokoro library. On first generation, the node loads kokoro-v1_0.pth from ComfyUI/models/Kokorotts/Kokoro-82M/, then builds a KPipeline whose language code is derived from the voice you chose (the af_/am_ prefix means American English, jf_/jm_ Japanese, zf_/zm_ Chinese, and so on). Your text goes through Kokoro's misaki phonemizer into phonemes, then the model synthesizes the waveform. The model is cached in memory between runs, so back-to-back generations are quick; that's what the unload_model toggle controls (more below).

    The pack's headline feature is two-person dialogue: flip enable_dialogue on, mark turns in your text with [S1] and [S2] tags, and each speaker's lines get routed to its own voice. The English dialogue example ships with af_heart.pt and am_echo.pt - a female/male pairing - and it works because each voice has its own lang_code pipeline while sharing one loaded model.

    Inputs and outputs

    • voice - dropdown of 54 voices covering American/British English, Japanese, Chinese, Spanish, French, Hindi, Italian, and Brazilian Portuguese. Default is zm_yunyang.pt.
    • text - the thing to speak. Note it's forceInput: true, so it's a socket, not a widget: you can't just click and type. Wire it from a text node (like this pack's MultiLinePromptKK) or any STRING source.
    • unload_model - default true, which frees the model and CUDA cache after each run. Leave it on unless you're doing a long batch and want to avoid reload churn.
    • enable_dialogue - off by default. On, plus [S1]/[S2] tags, gives you two voices.
    • voice_s2 - the second speaker, default zf_xiaobei.pt.

    Output is a single audio (AUDIO, 24000 Hz) socket - wire it into core PreviewAudio to hear it in the UI or SaveAudio/SaveAudioMP3 to write a file (that's exactly what the bundled workflows do).

    Install

    Via ComfyUI Manager, search for ComfyUI_KokoroTTS_MW. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/billwuhao/ComfyUI_KokoroTTS_MW
    cd ComfyUI_KokoroTTS_MW
    pip install -r requirements.txt
    

    Portable Windows installs use ./python_embeded/python.exe -m pip install -r requirements.txt instead. Requirements are kokoro plus the misaki[zh], misaki[ja], misaki[en] phonemizer extras - expect a chunky torch dependency pull on first install.

    The model does not auto-download. Grab Kokoro-82M from Hugging Face and lay it out exactly like this:

    ComfyUI/models/Kokorotts/Kokoro-82M/
    ├── voices/
    ├── config.json
    └── kokoro-v1_0.pth
    

    Where people get burned

    • Missing model files. The node silently errors on a missing .pth or voice file - the manual download step is the #1 stumbling block.
    • Forgot the [S1]/[S2] tags. With enable_dialogue on and no tags, the parser raises "No speaker tags found in the text" before anything plays.
    • CPU-only is slow. It falls back to CPU when no CUDA is available; fine for a sentence, painful for a page. If you're on a big narrative, chunk the text or get a GPU involved.
    • No text widget. Because text is forceInput, beginners click it and see nothing typeable. Wire in a multiline text node - that's the whole reason the pack ships one.
    Category🎤MW/MW-KokoroTTS

    Inputs (5)

    NameTypeDefaultDescription
    voiceCOMBOzm_yunyang.pt54 options: af_alloy.pt, af_aoede.pt, af_bella.pt, af_heart.pt, af_jessica.pt, af_kore.pt, +48
    textSTRING
    unload_modelBOOLEANtrue
    enable_dialogueoptBOOLEANfalse
    voice_s2optCOMBOzf_xiaobei.pt54 options: af_alloy.pt, af_aoede.pt, af_bella.pt, af_heart.pt, af_jessica.pt, af_kore.pt, +48

    Outputs (1)

    NameTypeDescription
    audioAUDIO