Skip to main content

Generate audio from text scripts using self-hosted Bark model and Google Drive

Workflow preview

Workflow preview
100%
Generate audio from text scripts using self-hosted Bark model and Google Drive preview
Open on n8n.io

Important notice

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

1. Workflow Overview

Audio Generator – Documentation Purpose: Generate audio files from text scripts stored in Google Drive. Flow: 1. Receive repo IDs. 2. Fetch text scripts. 3. Generate .wav files using local Ba...

Best for

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

Tools used

n8n-nodes-base.executeworkflowtrigger, n8n-nodes-base.manualtrigger, n8n-nodes-base.set, n8n-nodes-base.aggregate, n8n-nodes-base.googledrive, n8n-nodes-base.splitinbatches, n8n-nodes-base.readwritefile, n8n-nodes-base.executecommand

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Generate audio from text scripts using self-hosted Bark model and Google Drive
Workflow name
Generate audio from text scripts using self-hosted Bark model and Google Drive

Audio Generator – Documentation

🎯 Purpose: Generate audio files from text scripts stored in Google Drive.

🔁 Flow:

  1. Receive repo IDs.
  2. Fetch text scripts.
  3. Generate .wav files using local Bark model.
  4. Upload back to Drive.

📦 Dependencies:

  • Python script: /scripts/generate_voice.py
  • Bark (voice generation system)
  • n8n instance with access to local shell
  • Google Drive OAuth2 credentials

✏️ Notes:

  • Script filenames must end with .txt
  • Only works with plain text
  • No external API used = 100% free

📦 /scripts/generate_voice.py:

import sys
import torch
import numpy
import re
from bark import SAMPLE_RATE, generate_audio, preload_models
from scipy.io.wavfile import write as write_wav

# Patch to allow numpy._core.multiarray.scalar during loading
torch.serialization.add_safe_globals([numpy._core.multiarray.scalar])

# Monkey patch torch.load to force weights_only=False
_original_torch_load = torch.load
def patched_torch_load(f, *args, **kwargs):
    if 'weights_only' not in kwargs:
        kwargs['weights_only'] = False
    return _original_torch_load(f, *args, **kwargs)
torch.load = patched_torch_load

# Preload Bark models
preload_models()

def split_text(text, max_len=300):
    # Split on punctuation to avoid mid-sentence cuts
    sentences = re.split(r'(?<=[.?!])\s+', text)
    chunks = []
    current = ""
    for sentence in sentences:
        if len(current) + len(sentence) < max_len:
            current += sentence + " "
        else:
            chunks.append(current.strip())
            current = sentence + " "
    if current:
        chunks.append(current.strip())
    return chunks

# Input text file and output path
input_text_path = sys.argv[1]
output_wav_path = sys.argv[2]

with open(input_text_path, 'r', encoding='utf-8') as f:
    full_text = f.read()

voice_preset = "v2/en_speaker_7"

chunks = split_text(full_text)

# Generate and concatenate audio chunks
audio_arrays = []
for chunk in chunks:
    print(f"Generating audio for chunk: {chunk[:50]}...")
    audio = generate_audio(chunk, history_prompt=voice_preset)
    audio_arrays.append(audio)

# Merge all audio chunks
final_audio = numpy.concatenate(audio_arrays)

# Write final .wav file
write_wav(output_wav_path, SAMPLE_RATE, final_audio)

print(f"Full audio generated at: {output_wav_path}")

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 - Start: External Trigger

Type / Role
n8n-nodes-base.executeWorkflowTrigger - executeWorkflowTrigger
Config choices
Version 1.1

Block 2 - Start: Manual Test

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

Block 3 - Test Values

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

Block 4 - Aggregate Inputs

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

Block 5 - Get Scripts

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Block 6 - Loop Scripts

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 7 - Download Script

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Block 8 - Save Script

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

Block 9 - Generate WAV

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

Block 10 - Read Audio

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

Block 11 - Upload Audio

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Block 12 - 📝 Workflow Instructions

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

3. Summary Table

Workflow Generate audio from text scripts using self-hosted Bark model and Google Drive
Complexity intermediate
Nodes 12
Categories Content Creation, Multimodal AI
Author Flavien
Published 20 May 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/4241/4241.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 Generate audio from text scripts using self-hosted Bark model and Google Drive do?

Audio Generator – Documentation Purpose: Generate audio files from text scripts stored in Google Drive. Flow: 1. Receive repo IDs. 2. Fetch text scripts. 3. Generate .wav files using local Ba...

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.