Skip to content

E-Lab Audio Production test - Main Workflow

This workflow automates the conversion of E-Lab educational scripts into professional audio files using AI text-to-speech technology. It processes uploaded script files, extracts narrated segments, generates audio using different voices for characters and narrators, and organizes the final audio files in Google Drive with comprehensive tracking in Airtable.

Purpose

No business context provided yet — add a context.md to enrich this documentation.

How It Works

  1. Script Submission: Users submit E-Lab scripts through a web form, providing lesson details and uploading script files (.txt or .docx)
  2. Record Creation: The system creates an Airtable record to track the processing job with a unique Script ID and timestamp
  3. Status Tracking: Updates the processing status to "Processing" for monitoring purposes
  4. Script Parsing: Analyzes the uploaded script to identify different segment types (INTRO, LESSON, DIALOGUE, CORRECT, INCORRECT) and assigns appropriate voices
  5. Content Routing: Separates single-narrator segments from multi-character dialogue segments for different processing paths
  6. Audio Generation:
    • Single segments: Generates audio directly using ElevenLabs API
    • Dialogue segments: Creates individual audio files for each character, then merges them with silence gaps using FFmpeg
  7. File Storage: Uploads all generated audio files to a designated Google Drive folder
  8. Results Compilation: Merges processing results and calculates completion statistics
  9. Final Update: Updates the Airtable record with completion status, file links, and processing metrics

Workflow Diagram

graph TD
    A[Form Trigger] --> B[Create Airtable Record]
    B --> C[Update Status to Processing]
    C --> D[Parse Script]
    D --> E{Is Dialogue?}
    E -->|No| F[Generate Single Audio]
    E -->|Yes| G[Split Dialogue Parts]
    F --> H[Upload to Google Drive - Single]
    G --> I[Generate Dialogue Part]
    I --> J[Aggregate Dialogue Parts]
    J --> K[Merge Dialogue with FFmpeg]
    K --> L[Upload to Google Drive - Dialogue]
    H --> M[Merge Results]
    L --> M
    M --> N[Calculate Stats]
    N --> O[Update Airtable - Complete]

Trigger

Form Trigger: A web form accessible via webhook that accepts: - Lesson Number (required number field) - Lesson Name (required text field) - Script File (required file upload, accepts .txt and .docx files)

Nodes Used

Node Type Purpose
Form Trigger Provides web interface for script submission
Airtable (Create) Creates initial tracking record for the processing job
Airtable (Update) Updates processing status and final results
Code (Parse Script) Extracts and categorizes narrated segments from script content
If Routes content based on whether it's dialogue or single-narrator
HTTP Request Calls ElevenLabs API for text-to-speech generation
Code (Split Dialogue) Separates multi-character dialogue into individual parts
Aggregate Collects dialogue parts for merging
Code (FFmpeg Merge) Combines dialogue audio files with silence gaps
Google Drive Uploads generated audio files to cloud storage
Merge Combines results from different processing paths
Code (Calculate Stats) Computes processing metrics and file information

External Services & Credentials Required

ElevenLabs API

  • Purpose: Text-to-speech audio generation
  • Credential Type: elevenLabsApi
  • Required: API key for ElevenLabs service

Google Drive API

  • Purpose: Audio file storage and organization
  • Credential Type: Google OAuth2 or Service Account
  • Required: Access to Google Drive with folder creation/upload permissions

Airtable API

  • Purpose: Job tracking and progress monitoring
  • Credential Type: Airtable API key or OAuth
  • Required: Access to specified Airtable base with read/write permissions

Environment Variables

Variable Purpose Example
AIRTABLE_BASE_ID Target Airtable base for tracking records appXXXXXXXXXXXXXX
GOOGLE_DRIVE_FOLDER_ID Destination folder for audio files 1BxXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ELEVENLABS_VOICE_LINDA Voice ID for Linda character 21m00Tcm4TlvDq8ikWAM
ELEVENLABS_VOICE_JAMES Voice ID for James character 2EiwWnXFnvU5JabPnv8n
ELEVENLABS_VOICE_MARK Voice ID for Mark character AZnzlk1XvdvUeBnXmlld
ELEVENLABS_VOICE_JANE Voice ID for Jane character EXAVITQu4vr4xnSDxMaL
ELEVENLABS_VOICE_PETER Voice ID for Peter character ErXwobaYiN019PkySvjV

Data Flow

Input

  • Lesson Number: Integer identifying the lesson sequence
  • Lesson Name: Descriptive title for the lesson
  • Script File: Text or Word document containing E-Lab script with segment markers

Processing

  • Segments are identified by markers like EDU_X_1_Y patterns
  • Voice assignment follows character mapping (Guide→Linda, Practitioner→James, etc.)
  • Narrator voices rotate through available options for variety
  • Dialogue segments include 400ms silence between character lines

Output

  • Audio Files: MP3 files stored in Google Drive, named by segment ID
  • Airtable Record: Updated with completion status, file count, processing time, and Drive folder link
  • File Metadata: JSON array of segment IDs, filenames, and Drive URLs

Error Handling

The workflow includes basic error handling for: - FFmpeg Processing: Catches and reports audio merging errors - File Cleanup: Removes temporary files even if processing fails - API Failures: ElevenLabs and Google Drive API errors will stop execution with error details

No comprehensive retry logic or fallback mechanisms are currently implemented.

Known Limitations

  • Requires FFmpeg to be installed on the n8n server for dialogue merging
  • Limited to .txt and .docx file formats for script upload
  • Voice assignment is hardcoded and cannot be customized per job
  • No validation of script format before processing begins
  • Temporary files are stored in /tmp/elab_audio which may have space limitations

No related workflows specified in the current context.

Setup Instructions

  1. Import Workflow: Import the JSON into your n8n instance

  2. Configure Credentials:

    • Set up ElevenLabs API credentials with your API key
    • Configure Google Drive OAuth2 or Service Account credentials
    • Add Airtable API credentials with base access
  3. Set Environment Variables:

    • Configure all required environment variables in your n8n settings
    • Ensure voice IDs correspond to your ElevenLabs account voices
  4. Prepare Airtable Base:

    • Create a "Scripts" table with the following fields:
      • Script ID (Single line text)
      • Script Name (Single line text)
      • Lesson Number (Number)
      • Lesson Name (Single line text)
      • Upload Date (Date)
      • Status (Single select: Pending, Processing, Complete)
      • Total Segments (Number)
      • Processing Time (Number)
      • Drive Folder Link (URL)
      • Audio Files (Long text)
  5. Set Up Google Drive:

    • Create a dedicated folder for audio files
    • Note the folder ID from the URL for the environment variable
  6. Install Dependencies:

    • Ensure FFmpeg is installed on your n8n server: apt-get install ffmpeg
  7. Test the Workflow:

    • Activate the workflow
    • Access the form trigger URL
    • Submit a test script to verify end-to-end functionality
  8. Monitor Processing:

    • Check Airtable records for job status
    • Verify audio files appear in the designated Google Drive folder