DEV Community

VoiceDeveloper
VoiceDeveloper

Posted on

How to Build a Podcast Intro Generator

What You’ll Build

By the end of this post you’ll have a tiny but powerful “Podcast Intro Generator” that:

  • Accepts a podcast title, host name, and a short tagline.
  • Dynamically stitches those strings together into a polished intro script.
  • Sends that script to a text‑to‑speech engine.
  • Returns a high‑quality audio clip you can drop straight into your podcast editing workflow.

We’ll use ElevenLabs for the heavy lifting—its API gives us instant, human‑like voices and even voice‑cloning capabilities. If you’re new to TTS or looking for a quick, production‑ready solution, ElevenLabs is the sweet spot.


Why Voice AI for Podcasts?

  • Speed: Generate dozens of intros in seconds rather than recording a few minutes of audio.
  • Consistency: Same voice quality across all episodes, even if the host changes.
  • Customization: Swap in fresh intros, change the host’s voice, or add new branding elements on the fly.
  • Cost‑effective: No studio, no engineers, no extra gear.

If you’re a developer who loves APIs, you’ll appreciate how clean ElevenLabs’ REST interface is. All you need is an API key and a bit of JSON.


Step 1: Get Your ElevenLabs API Key

  1. Sign up (or log in) at https://try.elevenlabs.io/kr07zfuqn1bp.
  2. Navigate to the API tab in your dashboard.
  3. Copy your API Key and store it in an environment variable:
export ELEVENLABS_API_KEY="YOUR_API_KEY"
Enter fullscreen mode Exit fullscreen mode

Tip: Keep the key secret. Treat it like a password and never commit it to version control.


Step 2: Build the Intro Script

A typical intro might read:

“Welcome to Tech Talk, the podcast where Alex dives deep into the latest gadgets. Stay tuned for an episode you won’t want to miss.”

We’ll create a small function that accepts the podcast name, host name, and tagline, then returns a ready‑to‑speak string.

Python

def build_intro(podcast, host, tagline):
    return (
        f"Welcome to {podcast}, the podcast where "
        f"{host} dives deep into the latest gadgets. "
        f"{tagline}"
    )
Enter fullscreen mode Exit fullscreen mode

JavaScript (Node.js)

function buildIntro(podcast, host, tagline) {
  return `Welcome to ${podcast}, the podcast where 
          ${host} dives deep into the latest gadgets. 
          ${tagline}`;
}
Enter fullscreen mode Exit fullscreen mode

Step 3: Send the Script to ElevenLabs

ElevenLabs offers multiple voice models, including Standard, Creative, and Voice Cloning. For an intro, the Standard model works great for most podcasts, but if you want a unique host voice, you can upload an audio sample and generate a cloned model.

Below are three ways to call the API: Python, JavaScript, and cURL.

Python Example

import os
import requests

API_KEY = os.getenv("ELEVENLABS_API_KEY")
VOICE_ID = "Rachel"  # Pick a voice from the dashboard

def synthesize_text(text):
    url = "https://api.elevenlabs.io/v1/text-to-speech/{}".format(VOICE_ID)
    headers = {
        "accept": "audio/mpeg",
        "xi-api-key": API_KEY,
        "Content-Type": "application/json",
    }
    payload = {
        "text": text,
        "voice_settings": {"stability": 0.75, "similarity_boost": 0.75},
    }
    response = requests.post(url, json=payload, headers=headers)
    response.raise_for_status()
    return response.content

intro_text = build_intro("Tech Talk", "Alex", "Stay tuned for an episode you won’t want to miss.")
audio_bytes = synthesize_text(intro_text)

with open("intro.mp3", "wb") as f:
    f.write(audio_bytes)
print("Intro generated!")
Enter fullscreen mode Exit fullscreen mode

JavaScript (Node.js)

const fetch = require('node-fetch');
require('dotenv').config();

const API_KEY = process.env.ELEVENLABS_API_KEY;
const VOICE_ID = 'Rachel'; // Replace with your chosen voice ID

async function synthesizeText(text) {
  const url = `https://api.elevenlabs.io/v1/text-to-speech/${VOICE_ID}`;
  const response = await fetch(url, {
    method: 'POST',
    headers: {
      'accept': 'audio/mpeg',
      'xi-api-key': API_KEY,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      text,
      voice_settings: { stability: 0.75, similarity_boost: 0.75 },
    }),
  });

  if (!response.ok) throw new Error('Failed to synthesize text');
  return Buffer.from(await response.arrayBuffer());
}

(async () => {
  const introText = buildIntro('Tech Talk', 'Alex', 'Stay tuned for an episode you won’t want to miss.');
  const audio = await synthesizeText(introText);
  require('fs').writeFileSync('intro.mp3', audio);
  console.log('Intro generated!');
})();
Enter fullscreen mode Exit fullscreen mode

cURL

curl -X POST "https://api.elevenlabs.io/v1/text-to-speech/Rachel" \
     -H "accept: audio/mpeg" \
     -H "xi-api-key: $ELEVENLABS_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
           "text": "Welcome to Tech Talk, the podcast where Alex dives deep into the latest gadgets. Stay tuned for an episode you won’t want to miss.",
           "voice_settings": {"stability":0.75,"similarity_boost":0.75}
         }' --output intro.mp3
Enter fullscreen mode Exit fullscreen mode

Step 4: Automate the Workflow

If you’re producing multiple episodes, you can wrap the above logic into a small CLI tool or a simple web service.

# podcast_intro_cli.py
import argparse
import os
from pathlib import Path

def main():
    parser = argparse.ArgumentParser(description="Generate a podcast intro.")
    parser.add_argument("--podcast", required=True)
    parser.add_argument("--host", required=True)
    parser.add_argument("--tagline", required=True)
    parser.add_argument("--output", default="intro.mp3")
    args = parser.parse_args()

    intro_text = build_intro(args.podcast, args.host, args.tagline)
    audio_bytes = synthesize_text(intro_text)
    Path(args.output).write_bytes(audio_bytes)
    print(f"Intro saved to {args.output}")

if __name__ == "__main__":
    main()
Enter fullscreen mode Exit fullscreen mode

Run it like:

python podcast_intro_cli.py \
  --podcast "Tech Talk" \
  --host "Alex" \
  --tagline "Stay tuned for an episode you won’t want to miss." \
  --output "episode1_intro.mp3"
Enter fullscreen mode Exit fullscreen mode

Now you have a repeatable, version‑controlled pipeline for intros.


Going Beyond: Voice Cloning

If your podcast features multiple hosts or you want a consistent brand voice, ElevenLabs’ Voice Cloning lets you create a custom voice from a few minutes of audio.

  1. Upload a sample audio file through the dashboard or API.
  2. Once the model is ready, use its VOICE_ID in the same synth call as above.
  3. The result is a voice that sounds exactly like the sample speaker.

Pro Tip: Combine cloned voices with dynamic text (e.g., episode titles) to make each intro feel personalized.


Common Pitfalls & Debugging

Problem Fix
401 Unauthorized Check your API key and make sure it’s in ELEVENLABS_API_KEY.
Rate limit exceeded ElevenLabs enforces limits on free tiers. Upgrade or cache results.
Audio file corrupt Ensure you’re writing the binary data correctly (rb vs w).
Voice ID not found Verify the voice exists in your dashboard.

Final Thoughts

Building a podcast intro generator is surprisingly simple when you have a robust TTS service in your toolkit. ElevenLabs gives you:

  • High‑fidelity audio that rivals studio recordings.
  • Flexible voice selection and the option for full voice cloning.
  • A clean, well‑documented API that works in any language.

All the heavy lifting—deep learning, audio processing, voice synthesis—is handled behind the scenes. You get to focus on the creative side: crafting the script, branding, and episode flow.


Ready to Try It Out?

If you’re excited to start generating intros in seconds, head over to https://try.elevenlabs.io/kr07zfuqn1bp and grab your API key. Build, iterate, and let your podcast sound as polished as it deserves to be. Happy coding—and happy podcasting!

Top comments (0)