How aastroza/ai-podcast-generator works
Project Type and Purpose
• This is an open-source CLI tool (“AI Podcast Generator”) that automates the end-to-end creation of podcast scripts and audio. It reads a YAML spec, uses an AI text generator (via Marvin/OpenAI), converts script segments to speech (via Play.ht), and stitches the audio together (via pydub).
Key Components (to show
a. CLI / Orchestration Layer
• podcast.py (entry point)
• src/utils.py (config loading, file management)
b. Configuration
• YAML config file (examples/…/podcast.YAML)
• data/voices.json (metadata for available voices)
• .env (environment variables for OPENAI_API_KEY, PLAYHT_USER_ID, PLAYHT_SECRET)
c. Script Generation Service
• src/chat.py → wraps Marvin/OpenAI calls
d. Text-to-Speech Service
• src/audio.py → Play.ht API client
e. Audio Processing
• pydub (merge audio segments into final MP3)
f. File System
• Input folder (examples/…)
• Output folder (as specified in YAML)
• Intermediate files (JSON transcripts, per-segment MP3s)
g. External Services
• OpenAI (via Marvin client)
• Play.ht REST API
Component Relationships and Data Flow
1. User invokes CLI: python podcast.py --input podcast.YAML.
2. CLI loads YAML & voices.json via utils, loads API keys from .env.
3. For each “talk turn” (host, guest, topics) → chat.py → Marvin/OpenAI → returns script text segments.
4. Each segment passed to audio.py → Play.ht API → returns TTS MP3 URLs or binary.
5. CLI downloads/saves each segment (examples/…/*.mp3, *.json transcripts).
6. pydub merges all segment MP3s into a single podcast file.
7. Final MP3 written to the output folder.
Architectural Patterns and Design Principles
• Modular Pipeline: clear separation between configuration, script generation, TTS conversion, and audio merging.
• Single Responsibility: each src module handles one concern.
• External Service Adapters: wrappers around OpenAI and Play.ht.
• File-based staging: uses local filesystem for inputs, outputs, and intermediates.