Local Text-to-Speech Generation using KOKORO TTS - n8n Workflow

A powerful n8n workflow for local Text-to-Speech (TTS) generation using KOKORO and Python. Easily integrate custom audio generation into any n8n automation pipeline.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Users who need to perform Text-to-Speech generation locally rather than relying on external APIs.
Developers integrating custom, local Python scripts into their broader n8n automation solutions.
Users looking for advanced n8n templates demonstrating the use of the Execute Command n8n node.
Technical users running self-hosted n8n instances who require access to local file systems and executables.

Overview

This advanced n8n workflow is designed for scenarios where localized, high-performance audio generation is required. While many n8n templates focus on integrating cloud services, this solution leverages the Execute Command n8n node to bridge the gap between the n8n platform and powerful, on-premise software like KOKORO TTS. This approach provides flexibility and eliminates latency associated with external service calls for generation tasks.

The n8n workflow starts by defining the content and voice profile. It then triggers the local Python script, generating an MP3 audio file on the local machine. Finally, the generated audio file is imported back into the n8n execution flow, allowing subsequent n8n nodes to process, store, or transmit the binary audio data. This entire process demonstrates the power of the n8n platform to orchestrate complex, hybrid cloud/local automation tasks.

How it Works

This structured n8n workflow executes a four-step process to achieve local Text-to-Speech conversion:


  1. Trigger and Input: The n8n workflow starts with the Manual Trigger n8n node, serving as the initial n8n trigger point for execution.

  2. Define Variables: The 'Passing variables' Set n8n node initializes the payload, defining the required text (e.g., "Hello world!") and the desired voice profile (e.g., "af_sarah").

  3. Execute Local Script: The core 'Run python script' Execute Command n8n node takes these variables and executes the configured Python executable (C:\KOKORO\voicegen.py), passing the input text and voice variables as command-line arguments. This script handles the actual TTS generation using KOKORO, resulting in an output file (e.g., D:\output.mp3).

  4. Retrieve Output: The final 'Play sound' Read Binary Files n8n node accesses the local file system path (D:\output.mp3) and reads the newly created MP3 file, converting it into binary data within the n8n execution context, making it available for downstream processing in the n8n workflow.

Installation Guide

To use this specific n8n workflow, ensure you have the following prerequisites met:


  1. Import the n8n template: Copy the provided JSON and import it into your n8n instance using the 'New' -> 'Import from JSON' option.

  2. Local Setup: This n8n automation is dependent on a specific local setup. You must have KOKORO TTS installed and accessible on the machine running the n8n instance (or n8n self-hosted solution).

  3. Python Script: The required Python script (voicegen.py) must exist at the path defined in the 'Run python script' n8n node (C:\KOKORO\voicegen.py). This script needs to be correctly configured to interface with KOKORO TTS and save the output audio to D:\output.mp3.

  4. Execute Command Configuration: If your local paths or file names differ, you must update the command parameter in the 'Run python script' n8n node and the fileSelector in the 'Play sound' n8n node accordingly.

Node Details

Start (Manual Trigger n8n node): Serves as the initial n8n trigger to manually start the TTS generation process.
Passing variables (Set n8n node): Defines the critical input parameters needed for the external script execution. Key Configuration: JSON output is set to define voice and text values.
Run python script (Execute Command n8n node): The central component of this n8n workflow, executing the external Python script. Key Configuration: The command uses expressions to dynamically pass variables: =python C:\KOKORO\voicegen.py "{{ $json.text }}" "{{ $json.voice }}" 1.
Play sound (Read Binary Files n8n node): Reads the generated audio file back into the n8n context for further steps. Key Configuration: File Selector is set to the specific local output path (D:\output.mp3).

Related n8n Workflows

Free

Nodes: 4 Nodes
Updated: December 26 2025
View all
Created by
Stas
Stas

Do you have a vision or project in mind? Allow me to bring it to life with the utmost design excellence. With over 15 years of experience in the industry, I guarantee that your designs will surpass those of your competitors.

Featured*