Skip to main content

Convert text to speech with local KOKORO TTS

Workflow preview

Workflow preview
100%
Convert text to speech with local KOKORO TTS preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Disclaimer The Execute Command node is only supported on self hosted (local) instances of n8n. Introduction KOKORO TTS Kokoro TTS is a compact yet powerful text to speech mode...

Best for

  • Content Creation automation workflows
  • Multimodal AI automation workflows
  • beginner n8n builders looking for reusable templates

Tools used

n8n-nodes-base.executecommand, n8n-nodes-base.set, n8n-nodes-base.manualtrigger, n8n-nodes-base.readbinaryfiles

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by bswlife.

Original n8n.io source

1.1 Workflow description

Title
Convert text to speech with local KOKORO TTS
Workflow name
Convert text to speech with local KOKORO TTS

Disclaimer

The Execute Command node is only supported on self-hosted (local) instances of n8n.

Introduction

KOKORO TTS - Kokoro TTS is a compact yet powerful text-to-speech model, currently available on Hugging Face and GitHub. Despite its modest size—trained on less than 100 hours of audio—it delivers impressive results, consistently topping the TTS leaderboard on Hugging Face. Unlike larger systems, Kokoro TTS offers the advantage of running locally, even on devices without GPUs, making it accessible for a wide range of users.

Who will benefit from this integration?

This will be useful for video bloggers, TikTokers, and it will also enable the creation of a free voice chat bot. Currently, TTS models are mostly paid, but this integration will allow for fully free voice generation. The possibilities are limited only by your imagination.

Note

Unfortunately, we can't interact with the KOKORO API via browser URL (GET/POST), but we can run a Python script through n8n and pass any variables to it.

In the tutorial, the D drive is used, but you can rewrite this for any paths, including the C drive.

Step 1

You need to have Python installed. link Also, download and extract the portable version of KOKORO from GitHub.

Create a file named voicegen.py with the following code in the KOKORO folder: (C:\KOKORO). As you can see, the output path is: (D:\output.mp3).

import sys
import shutil
from gradio_client import Client

# Set UTF-8 encoding for stdout
sys.stdout.reconfigure(encoding='utf-8')

# Get arguments from command line
text = sys.argv[1] # First argument: input text
voice = sys.argv[2] # Second argument: voice
speed = float(sys.argv[3]) # Third argument: speed (converted to float)

print(f"Received text: {text}")
print(f"Voice: {voice}")
print(f"Speed: {speed}")

# Connect to local Gradio server
client = Client("http://localhost:7860/")

# Generate speech using the API
result = client.predict(
text=text,
voice=voice,
speed=speed,
api_name="/generate_speech"
)

# Define output path
output_path = r"D:\output.mp3"

# Move the generated file
shutil.move(result[1], output_path)

# Print output path
print(output_path)

Step 2

Go to n8n and create the following workflow.

Step 3

Edit Field Module.

{
  "voice": "af_sarah",
  "text": "Hello world!"
}

Step 4

We’ll need an Execute Command module with the command: python

C:\KOKORO\voicegen.py “{{ $json.text }}” “{{ $json.voice }}” 1

Step 5

The script is already working, but to listen to it, you can connect a Binary module with the path to the generated MP3 file

D:/output.mp3

Step 6

Click “Text workflow” and enjoy the result.

There are more voices and accents than in ChatGPT, plus it’s free.

P.S.

If you want, there is a detailed tutorial on my blog.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Run python script

Type / Role
n8n-nodes-base.executeCommand - executeCommand
Config choices
Version 1

Block 2 - Passing variables

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 3 - Start

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 4 - Play sound

Type / Role
n8n-nodes-base.readBinaryFiles - readBinaryFiles
Config choices
Version 1

3. Summary Table

Workflow Convert text to speech with local KOKORO TTS
Complexity beginner
Nodes 4
Categories Content Creation, Multimodal AI
Author bswlife
Published 14 Apr 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/3547/3547.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Convert text to speech with local KOKORO TTS do?

Disclaimer The Execute Command node is only supported on self hosted (local) instances of n8n. Introduction KOKORO TTS Kokoro TTS is a compact yet powerful text to speech mode...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Content Creation, Multimodal AI use case.