Why a Podcast Intro Generator?
A great intro sets the tone for a show, but recording it every episode can become a tedious chore—especially if you’re juggling production, editing, and promotion. With modern voice AI, you can automate the whole process: write a short script, feed it to a text‑to‑speech (TTS) engine, sprinkle in some royalty‑free music, and you’ve got a polished intro ready to drop into every episode.
In this post I’ll walk you through building a Podcast Intro Generator from scratch using Python and the ElevenLabs API, a state‑of‑the‑art voice cloning platform. By the end you’ll have a reusable CLI tool that creates a 10‑second intro in a matter of seconds.
What You’ll Need
| Item | Reason |
|---|---|
| Python 3.9+ | Core language for the script |
| ElevenLabs API key | Access to high‑quality TTS and voice cloning |
| FFmpeg | Concatenate audio, normalize levels, and add background music |
| A short music loop (free from sites like Free Music Archive) | Gives the intro a professional feel |
| dotenv (optional) | Keep your API key out of source control |
If you don’t have an ElevenLabs account yet, sign up through this affiliate link: https://try.elevenlabs.io/kr07zfuqn1bp. You’ll get a generous free tier and instant access to the API.
Step 1: Set Up the ElevenLabs API
First, install the required Python packages:
pip install requests python-dotenv pydub
Create a .env file in your project root:
ELEVENLABS_API_KEY=your_api_key_here
Now we can wrap the API calls in a tiny helper class:
# elevenlabs.py
import os
import requests
from dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv("ELEVENLABS_API_KEY")
BASE_URL = "https://api.elevenlabs.io/v1"
def generate_speech(text: str, voice_id: str = "EXAVITQu4vr4xnSDxMaL", stability: float = 0.75, similarity_boost: float = 0.75) -> bytes:
"""
Sends a TTS request to ElevenLabs and returns raw MP3 bytes.
"""
url = f"{BASE_URL}/text-to-speech/{voice_id}"
headers = {
"xi-api-key": API_KEY,
"Content-Type": "application/json",
}
payload = {
"text": text,
"model_id": "eleven_monolingual_v1",
"voice_settings": {
"stability": stability,
"similarity_boost": similarity_boost,
},
}
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
return response.content
Note: The default
voice_idabove is ElevenLabs’ “Rachel” voice, which works well for most podcast niches. If you’ve cloned your own voice, just replace the ID with the one you received from the dashboard.
Step 2: Write the Intro Script Generator
A good intro is short, consistent, and includes three key pieces of info:
- Show name
- Episode number or title
- A tagline or call‑to‑action
Let’s generate that dynamically:
# script.py
def build_intro(show_name: str, episode_title: str, tagline: str) -> str:
return (
f"Welcome to {show_name}. "
f"This is the {episode_title} episode. "
f"{tagline}"
)
Example usage:
intro_text = build_intro(
show_name="Tech Talk Weekly",
episode_title="AI in 2024",
tagline="Stay curious, stay informed."
)
print(intro_text)
Output:
Welcome to Tech Talk Weekly. This is the AI in 2024 episode. Stay curious, stay informed.
Step 3: Convert Text to Speech
Now we combine the script generator with the ElevenLabs wrapper:
# generate_intro.py
from elevenlabs import generate_speech
from script import build_intro
from pydub import AudioSegment
def create_podcast_intro(show_name, episode_title, tagline, music_path, output_path):
# 1️⃣ Build the spoken script
text = build_intro(show_name, episode_title, tagline)
# 2️⃣ Get TTS audio (MP3 bytes)
speech_mp3 = generate_speech(text)
# 3️⃣ Load speech and background music with pydub
speech = AudioSegment.from_file(io.BytesIO(speech_mp3), format="mp3")
music = AudioSegment.from_file(music_path)
# 4️⃣ Trim music to the length of the speech and lower its volume
music = music[:len(speech)].apply_gain(-8) # -8 dB gives room for the voice
# 5️⃣ Overlay speech on top of music
intro = music.overlay(speech)
# 6️⃣ Export the final intro
intro.export(output_path, format="mp3")
print(f"✅ Intro saved to {output_path}")
# Example run
if __name__ == "__main__":
import io
create_podcast_intro(
show_name="Tech Talk Weekly",
episode_title="AI in 2024",
tagline="Stay curious, stay informed.",
music_path="assets/loop.wav",
output_path="output/intro.mp3",
)
Why pydub?
pydub is a thin wrapper around FFmpeg, letting you slice, fade, and mix audio without writing raw shell commands. If you prefer a pure‑curl approach, you can hit ElevenLabs directly:
curl -X POST "https://api.elevenlabs.io/v1/text-to-speech/EXAVITQu4vr4xnSDxMaL" \
-H "xi-api-key: $ELEVENLABS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Welcome to Tech Talk Weekly. This is the AI in 2024 episode. Stay curious, stay informed.",
"model_id": "eleven_monolingual_v1",
"voice_settings": {"stability":0.75,"similarity_boost":0.75}
}' \
--output intro.mp3
Both methods produce the same high‑fidelity MP3; pick the one that fits your workflow.
Step 4: Automate the Whole Pipeline
You probably want to generate an intro for every new episode automatically. Here’s a minimal CLI using argparse:
# cli.py
import argparse
from generate_intro import create_podcast_intro
def main():
parser = argparse.ArgumentParser(description="Podcast Intro Generator")
parser.add_argument("--show", required=True, help="Name of the podcast")
parser.add_argument("--episode", required=True, help="Episode title or number")
parser.add_argument("--tagline", default="Stay curious, stay informed.", help="Tagline")
parser.add_argument("--music", default="assets/loop.wav", help="Background music file")
parser.add_argument("--out", default="output/intro.mp3", help="Output MP3 path")
args = parser.parse_args()
create_podcast_intro(
show_name=args.show,
episode_title=args.episode,
tagline=args.tagline,
music_path=args.music,
output_path=args.out,
)
if __name__ == "__main__":
main()
Run it like:
python cli.py --show "Tech Talk Weekly" --episode "AI in 2024"
You’ll get a ready‑to‑use intro.mp3 you can drop into your editing timeline.
Bonus: Voice Cloning for a Signature Host
If you have a regular host voice you want to preserve, ElevenLabs lets you clone it with just a few minutes of audio. Upload a 30‑second sample in the dashboard, retrieve the new voice_id, and replace the default ID in generate_speech. The result? An intro that sounds exactly like your host, even if they’re on vacation.
Pro tip: Keep the clone audio clean (no background noise) and use the same microphone setup you use for regular recordings. The more consistent the source, the better the clone.
Testing & Quality Checks
- Length sanity – Make sure the generated intro is under 15 seconds. You can enforce this by trimming the speech or looping a shorter music clip.
-
Loudness – Use
pydub’snormalize()to keep the intro at around -14 LUFS, matching most podcast platforms. -
Error handling – Wrap the API call in a
try/exceptblock and retry on HTTP 429 (rate limit) or 5xx errors.
def safe_generate_speech(*args, **kwargs):
for attempt in range(3):
try:
return generate_speech(*args, **kwargs)
except requests.HTTPError as e:
if e.response.status_code == 429:
time.sleep(2 ** attempt) # exponential back‑off
else:
raise
raise RuntimeError("Failed to generate speech after 3 attempts")
What’s Next?
- Batch processing – Read a CSV of episode titles and spin out a whole season’s intros in one go.
- Dynamic music selection – Randomly pick a royalty‑free loop per episode for variety.
- Integration with your CI/CD – Hook the generator into a GitHub Action that runs whenever a new episode markdown file lands in your repo.
All of this is possible with just a few lines of code and the power of ElevenLabs’ TTS engine. The best part? You keep full control over the voice, style, and branding, without ever leaving your development environment.
Ready to Give It a Spin?
If you’ve followed along, you now have a fully functional Podcast Intro Generator that produces studio‑grade voiceovers in seconds. The only thing left is to try it with your own show.
Start experimenting with ElevenLabs today by signing up through this link: https://try.elevenlabs.io/kr07zfuqn1bp. The free tier gives you enough credits to build dozens of intros, and the API is rock‑solid for production workloads.
Happy coding, and may your intros always be crisp, clear, and captivating! 🚀
Top comments (0)