DEV Community

VoiceDeveloper
VoiceDeveloper

Posted on

How to Build a Podcast Intro Generator

What is a Podcast Intro Generator?

If you’ve ever launched a new show, you’ll know the first 30‑second hook is everything. A polished, brand‑consistent intro sets the tone, tells listeners what to expect, and can even boost discoverability. Building a “Podcast Intro Generator” lets you auto‑create custom intros for each episode or series without the tedious manual editing that normally comes with audio production.

The core of the solution is a small pipeline:

  1. Collect metadata (title, host name, show tagline, etc.)
  2. Generate a text prompt that describes the intro you want.
  3. Convert the prompt to speech with a TTS engine.
  4. Post‑process (trim, add music, normalize volume).

With modern voice‑AI platforms, the heavy lifting is almost entirely handled by the TTS engine. Below, I’ll walk you through building a minimal, reusable generator that leverages ElevenLabs’ voice‑cloning capabilities. (You can replace the API calls with any other provider if you prefer.)


1. Setting Up Your Environment

First, decide on a language. I’ll use Python 3.11 because of its great ecosystem for HTTP requests and audio manipulation. Install the essentials:

pip install requests pydub tqdm
Enter fullscreen mode Exit fullscreen mode
  • requests – simple HTTP client
  • pydub – audio editing (needs ffmpeg installed)
  • tqdm – progress bar for long downloads

Make sure ffmpeg is in your PATH; on macOS you can install it via Homebrew:

brew install ffmpeg
Enter fullscreen mode Exit fullscreen mode

2. Grab an API Key from ElevenLabs

ElevenLabs provides a straightforward REST API for text‑to‑speech and voice cloning. Sign up at their site and copy your API key. For this tutorial, I’ll keep it in an environment variable:

export ELEVENLABS_API_KEY="YOUR_API_KEY"
Enter fullscreen mode Exit fullscreen mode

Tip: Use the affiliate link https://try.elevenlabs.io/kr07zfuqn1bp to sign up and receive a free tier credit.


3. Designing the Prompt Engine

The trickiest part is turning episode data into a natural‑sounding script. Below is a simple function that stitches together a headline, host introduction, and a short tagline.

def build_intro_script(show_name, host_name, episode_title, tagline=None):
    intro = f"Welcome to {show_name}, the podcast where we dive deep into "
    intro += f"the world of {episode_title}. "
    intro += f"I'm {host_name}, and I'm thrilled to bring you today's discussion."
    if tagline:
        intro += f" {tagline}"
    intro += " Let's get started!"
    return intro
Enter fullscreen mode Exit fullscreen mode

Feel free to tweak the wording or add placeholders for custom music cues. The more descriptive the prompt, the better the TTS will sound.


4. Calling ElevenLabs’ TTS API

ElevenLabs supports both standard TTS and voice‑cloned voices. For a quick demo, we’ll use a pre‑trained voice. If you want your own voice, you can upload a few minutes of speech and let the model learn it.

import os
import json
import requests
from tqdm import tqdm

ELEVENLABS_API_KEY = os.getenv("ELEVENLABS_API_KEY")
BASE_URL = "https://api.elevenlabs.io/v1"

def synthesize_text(text, voice_id="21m00Tcm4TlvDq8ikWAM", stability=0.5, similarity=0.75):
    """
    Calls ElevenLabs TTS endpoint and streams the MP3 audio.
    """
    headers = {
        "xi-api-key": ELEVENLABS_API_KEY,
        "Content-Type": "application/json"
    }

    payload = {
        "text": text,
        "voice_settings": {
            "stability": stability,
            "similarity_boost": similarity
        },
        "voice_id": voice_id
    }

    response = requests.post(
        f"{BASE_URL}/text-to-speech/{voice_id}",
        headers=headers,
        data=json.dumps(payload),
        stream=True
    )

    if response.status_code != 200:
        raise Exception(f"API error: {response.status_code} {response.text}")

    return response.iter_content(chunk_size=1024)
Enter fullscreen mode Exit fullscreen mode

Pro tip: The voice_id "21m00Tcm4TlvDq8ikWAM" is ElevenLabs’ default “Rachel” voice. You can replace it with any voice you own or clone.


5. Streaming the Audio to a File

Because ElevenLabs streams the MP3 back in chunks, we’ll write a helper to save it incrementally.

def stream_to_file(iterable, output_path):
    with open(output_path, "wb") as f:
        for chunk in tqdm(iterable, desc="Downloading audio"):
            f.write(chunk)

# Example usage
script = build_intro_script(
    show_name="Tech Talk",
    host_name="Alex",
    episode_title="AI Ethics",
    tagline="Because the future is already here."
)

audio_chunks = synthesize_text(script)
stream_to_file(audio_chunks, "intro.mp3")
Enter fullscreen mode Exit fullscreen mode

After running this, intro.mp3 will contain a clean, 30‑second voice‑over that you can splice into your episode.


6. Adding Background Music

A great intro usually has a short music loop. With pydub, we can overlay a royalty‑free track:

from pydub import AudioSegment

def mix_intro_with_music(intro_path, music_path, output_path, music_volume=-12):
    # Load the files
    intro = AudioSegment.from_file(intro_path, format="mp3")
    music = AudioSegment.from_file(music_path, format="mp3")

    # Trim or loop music to match intro length
    if len(music) < len(intro):
        repeats = (len(intro) // len(music)) + 1
        music = music * repeats
    music = music[:len(intro)]

    # Adjust volume and mix
    music = music + music_volume
    mixed = intro.overlay(music)

    mixed.export(output_path, format="mp3")
    print(f"Mixed intro saved to {output_path}")

# Example
mix_intro_with_music("intro.mp3", "background.mp3", "final_intro.mp3")
Enter fullscreen mode Exit fullscreen mode

Keep the music low‑volume so it doesn’t overpower the voice.


7. Packaging It Into a CLI

For repeated use, wrap everything into a command‑line tool.

python intro_generator.py \
  --show "Tech Talk" \
  --host "Alex" \
  --episode "AI Ethics" \
  --tagline "Because the future is already here." \
  --music "background.mp3" \
  --output "episode1_intro.mp3"
Enter fullscreen mode Exit fullscreen mode

A simple argparse script will handle the arguments and orchestrate the pipeline.


8. Advanced: Voice Cloning

If you want your own voice (or a guest’s) in the intros, ElevenLabs lets you upload a short audio clip (5–10 minutes) and generates a new voice ID. Here’s a quick overview:

  1. Upload a voice sample
  2. Wait for the model to finish
  3. Use the returned voice_id in the synthesize_text call
def create_voice_clone(sample_path, name="Custom Voice"):
    headers = {
        "xi-api-key": ELEVENLABS_API_KEY,
        "Content-Type": "application/json"
    }
    files = {"file": open(sample_path, "rb")}
    data = {"name": name}
    response = requests.post(
        f"{BASE_URL}/voices",
        headers={"xi-api-key": ELEVENLABS_API_KEY},
        files=files,
        data=data
    )
    return response.json()["id"]
Enter fullscreen mode Exit fullscreen mode

Once you have the voice_id, replace the default in synthesize_text. The result will sound like you (or your guest), making the intro feel genuinely personal.


9. Testing & Iteration

  • Audio quality: Check the bitrate and sample rate. ElevenLabs returns 24 kHz MP3s, which is fine for most podcasts.
  • Timing: Make sure the intro length matches your episode’s intro slot.
  • Voice style: Adjust stability and similarity_boost to get a more formal or casual tone.

10. Final Thoughts

By combining a simple prompt engine, ElevenLabs’ powerful TTS, and a little audio mixing, you can automate the production of polished podcast intros in a few lines of code. The generator is lightweight, extensible, and can be integrated into larger CI/CD pipelines for automated episode publishing.

Want to try it out right now? Sign up at the affiliate link https://try.elevenlabs.io/kr07zfuqn1bp, grab your free API key, and start generating intros for your next episode. Happy podcasting!

Top comments (0)