Generate full podcast episodes with realistic multi-voice conversations on ANY topic using AI. Powered by Modal, Grok AI, and Qwen3-TTS.
- π Multi-Voice Podcasts: 3 distinct AI voices (Host, Expert, Comedian) with natural expressiveness
- π Parallel Generation: All audio segments generated simultaneously for speed
- π¬ Audio & Video: Create both audio podcasts (WAV) and video with waveform visualization (MP4)
- π¬ Natural Dialogue: Uses Grok AI to generate realistic, conversational scripts with filler words, interruptions, and natural pacing
- β‘ Fast: Full 2-3 minute podcast in under 90 seconds
- π Web Interface: Beautiful, responsive web UI included
- π° Cost Optimized: L4 GPU, parallel processing, auto-scaling
# 1. Clone and setup environment
git clone https://github.com/paarijat007/qwen3-tts-serverless.git
cd qwen3-tts-serverless
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# 2. Configure Modal
modal setup
# 3. Add your Grok API key
modal secret create grok-api-key GROK_API_KEY=your-xai-key
# 4. Deploy
modal deploy app.py
# 5. Open the URL Modal gives you
# Example: https://yourname--aiden-webrtc-tts-web.modal.runGenerate podcasts on any topic: "Why everyone's ex looks exactly the same", "The psychology of procrastination", etc.
User Topic β Grok AI Script β Parse Segments β Parallel TTS β Assembly β WAV/MP4
- Script Generation: Grok AI (
grok-4-1-fast-non-reasoning) creates natural dialogue between 3 personas (12-15 exchanges) - Parsing: Script is split into speaker segments (HOST/EXPERT/COMEDIAN), emotion tags removed
- Parallel Voice Synthesis: All segments generated simultaneously using
asyncio.gather()- this is the key speedup! - Assembly: Audio segments concatenated with 0.7s natural pauses between speakers
- Output: Return as WAV audio or MP4 video (with ffmpeg waveform visualization)
- HOST (Alex): Smooth, warm male voice - Joe Rogan style, naturally curious
- EXPERT (Dr. Sarah): Sophisticated female voice - approachable expert
- COMEDIAN (Mike): Witty male voice - naturally funny without forcing jokes
- Modal account - Free tier available (requires credit card for GPU access)
- Grok API key - Get from x.ai (~$5/1M tokens)
- Python 3.11+
- Clone the repository:
git clone https://github.com/paarijat007/qwen3-tts-serverless.git
cd qwen3-tts-serverless- Create virtual environment and install dependencies:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt- Configure Modal:
modal setup # Follow prompts to authenticate with your Modal account- Create Modal secret with your Grok API key:
modal secret create grok-api-key GROK_API_KEY=your-xai-api-key-hereThat's it! You're ready to deploy.
modal deploy app.pyThis will give you a URL like: https://yourusername--aiden-webrtc-tts-web.modal.run
modal serve app.pyThen open the local URL in your browser.
curl -X POST https://your-modal-url/generate-podcast \
-H "Content-Type: application/json" \
-d '{
"topic": "The future of AI",
"details": "Focus on alignment and safety concerns"
}'curl -X POST https://your-modal-url/generate-video \
-H "Content-Type: application/json" \
-d '{
"topic": "The future of AI",
"details": "Focus on alignment and safety concerns"
}'.
βββ app.py # Main Modal application (1034 lines)
β βββ TTS class (L4 GPU) # Qwen3-TTS model loader and generator
β βββ /generate-podcast # HTTP endpoint for audio podcasts
β βββ /generate-video # HTTP endpoint for video with waveform
β βββ /generate # Simple TTS endpoint
β βββ / (GET) # Web interface HTML
βββ philosophical_debate_modal.py # Philosophical debate variant (experimental)
βββ index.html # Standalone web interface
βββ .env.example # Environment variables template
βββ LICENSE # Apache 2.0 License
βββ README.md # This file
- Lines 102-136: TTS class with GPU configuration and model loading
- Lines 463-654: Main podcast generation endpoint (working, production-ready)
- Lines 657-866: Video generation with ffmpeg (working, production-ready)
- Lines 46-96: Voice profile prompts (customizable)
The TTS model runs on Modal's L4 GPU (app.py:103):
@app.cls(
gpu="L4", # Much cheaper than A100 (~8x cost savings)
cpu=2,
min_containers=0, # Scale to zero when idle = $0 cost
scaledown_window=300, # 5 minute cooldown
timeout=600, # 10 minute max execution
)- Cheap GPU: L4 instead of A100 for TTS model
- Parallel Processing: All segments generated simultaneously (not sequential)
- Fast LLM:
grok-4-1-fast-non-reasoningfor script generation - Auto-scaling: Containers scale down to 0 when idle (no idle costs)
- Efficient Model Loading: bfloat16 precision reduces memory usage
The key innovation is parallel TTS generation:
# All segments generated simultaneously, not sequentially!
results = await asyncio.gather(*[
tts.generate.remote(text, voice_style)
for speaker, text in segments
])This reduces generation time from ~5 minutes (sequential) to ~90 seconds (parallel).
Edit the voice descriptions in app.py (lines 46-96) to customize voice characteristics:
VOICE_HOST = """
Your custom voice description here...
"""# Generate a test podcast locally
modal run app.py::TTS.generate --text "Hello world" --voice-style "$VOICE_HOST"Add print() statements in the code - Modal captures all logs in the web dashboard.
- Generation Time: 90-180 seconds for full podcast (includes script + audio)
- Cold Start: First request adds ~30 seconds for GPU warmup
- Maximum Length: ~5 minutes per podcast (limited by
max_tokens=3000in Grok) - WebRTC: Experimental
/offerendpoint exists but not production-ready (use HTTP endpoints instead) - Video Size: MP4 files are large (~20-50MB for 2-3 min) due to waveform rendering
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
Apache License 2.0 - see LICENSE file for details.
- Modal - Serverless GPU infrastructure
- Qwen3-TTS - Voice synthesis
- Grok AI - Script generation
- aiortc - WebRTC implementation
For issues and questions:
- Open an issue on GitHub
- Check Modal docs: https://modal.com/docs
Built with Modal π