Skip to content

amazingchow/PodcastAgent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽ™๏ธ Podcast Agent

Python 3.12+ License: MIT Code style: ruff

An intelligent podcast creation tool based on large language models that automatically generates podcast timelines and dialogue content, with built-in self-reflection mechanisms to ensure high-quality content output.

โœจ Features

  • ๐Ÿค– Intelligent Timeline Generation: Automatically designs podcast structure based on theme, keywords, and duration
  • ๐Ÿ’ฌ Natural Dialogue Creation: Generates dialogue content that fits podcast style
  • ๐ŸŒ Multi-language Support: Supports both Chinese and English podcast creation
  • ๐ŸŽฏ Flexible Configuration: Supports custom hosts, guests, style, and other parameters
  • ๐Ÿ“Š Quality Scoring: Provides quality scores for each generated content segment
  • ๐Ÿ”„ Self-reflection Optimization: Built-in quality assessment mechanism for automatic iterative content optimization
  • ๐Ÿ’ฐ Cost Tracking: Real-time monitoring of LLM usage costs with detailed cost statistics and analysis

๐Ÿš€ Quick Start

Requirements

  • Python 3.12+
  • LLM API Key (via OpenRouter)

Installation

  1. Install the package
pip install podcast-agent
  1. Configure environment variables Create a .env file with the following variables:
OPENAI_API_KEY=your_api_key_here
OPENAI_BASE_URL=https://openrouter.ai/api/v1
MODEL_FOR_PODCAST=openai/gpt-5
MODEL_FOR_REFLECTION=google/gemini-2.5-pro

Usage Examples

Chinese Podcast Example

import podcast_agent as pa

pa.create_podcast(
    theme="ไบบๅทฅๆ™บ่ƒฝๅœจๅŒป็–—้ข†ๅŸŸ็š„ๅบ”็”จ",
    keywords_str="AI่ฏŠๆ–ญ, ๅŒป็–—ๅฝฑๅƒ, ไธชๆ€งๅŒ–ๆฒป็–—, ไผฆ็†้—ฎ้ข˜",
    host="ๆฝ˜ไนฑ๏ผˆไนฑ็ฟปไนฆไธป็†ไบบ๏ผ‰",
    guests_str="Adam Zhou๏ผˆๅๅฐๅญAI CEO๏ผ‰, ็Ž‹ๅปบ็ก•๏ผˆๆŸๅ›ฝๅ†…้กถๅฐ–ๅŒป้™ขไธปไปปๅŒปๅธˆ๏ผ‰",
    duration=20,
    style="ไธ“ไธšไธ”ๆ˜“ๆ‡‚, ๅฃ่ฏญๅŒ–, ่ฝปๆพๅนฝ้ป˜",
    language="ไธญๆ–‡"
)

English Podcast Example

import podcast_agent as pa

pa.create_podcast(
    theme="The Future of Artificial Intelligence in Healthcare",
    keywords_str="AI diagnosis, medical imaging, personalized treatment, ethical concerns, machine learning",
    host="Dr. Sarah Chen (AI Research Director)",
    guests_str="Dr. Michael Rodriguez (Chief Medical Officer), Prof. Lisa Thompson (AI Ethics Expert)",
    duration=25,
    style="Professional and engaging, conversational, accessible to general audience",
    language="English"
)

๐Ÿ“– Workflow

  1. Timeline Generation: Generate podcast structure based on input parameters
  2. Quality Assessment: Use reflection mechanism to evaluate timeline quality
  3. Content Creation: Generate dialogue content for each timeline segment
  4. Iterative Optimization: Automatically optimize content based on quality scores
  5. File Output: Save timeline and content to files

๐Ÿ“ Output Files

  • timeline_YYYYMMDD_HHMMSS.json: Timeline structure file
  • podcast_YYYYMMDD_HHMMSS.txt: Podcast content file
  • cost_stats_YYYYMMDD_HHMMSS.json: LLM usage cost statistics file

๐Ÿ’ฐ Cost Tracking

The system automatically tracks all LLM API calls and provides detailed cost statistics:

  • Real-time Cost Monitoring: Every API call records token usage and estimated cost
  • Multi-dimensional Analysis: Statistics broken down by operation type (timeline generation, content generation, reflection evaluation, etc.) and model
  • Cost Optimization Suggestions: Helps users understand which operations consume the most resources
  • Detailed Reports: Generates JSON report files containing all usage records

Supported Model Pricing

The system includes built-in pricing information for mainstream LLM models, including:

  • OpenAI GPT series
  • Google Gemini series

Cost Statistics Example

======================================================================
                     ๐Ÿ’ฐ LLM Usage Cost Statistics                      
======================================================================

๐Ÿ“Š Overall Statistics
  Total Tokens: 39,390
  Total Cost: $0.30458
  Average Cost per Token: $0.00000773
  Total Calls: 14

๐Ÿ”ง Breakdown by Operation
  Timeline Generation:
    Calls: 1
    Tokens: 2,851
    Cost: $0.02529
    Average per Call: $0.02529
  Reflection:
    Calls: 7
    Tokens: 20,083
    Cost: $0.13189
    Average per Call: $0.01884
  Content Generation:
    Calls: 6
    Tokens: 16,456
    Cost: $0.14740
    Average per Call: $0.02457

๐Ÿค– Breakdown by Model
  google/gemini-2.5-pro:
    Calls: 7
    Tokens: 19,307
    Cost: $0.17269
    Average per Call: $0.02467
  openai/gpt-5:
    Calls: 7
    Tokens: 20,083
    Cost: $0.13189
    Average per Call: $0.01884

๐Ÿ› ๏ธ Development

Project Structure

PodcastAgent/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ podcast_agent/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ”œโ”€โ”€ agent.py          # Podcast creation Agent
โ”‚       โ”œโ”€โ”€ models.py         # Data models
โ”‚       โ”œโ”€โ”€ openai_client.py  # OpenAI client wrapper
โ”‚       โ”œโ”€โ”€ reflection.py     # Reflection Agent for evaluating and improving generated content
โ”‚       โ””โ”€โ”€ utils.py          # Utility functions
โ”œโ”€โ”€ examples/
โ”‚   โ”œโ”€โ”€ example_zh.py         # Chinese podcast example
โ”‚   โ””โ”€โ”€ example_en.py         # English podcast example
โ”œโ”€โ”€ output/                   # Output files directory
โ”œโ”€โ”€ pyproject.toml            # Project configuration
โ””โ”€โ”€ README.md

Development Environment Setup

  1. Install development dependencies
uv sync
  1. Install pre-commit hooks
pre-commit install

Local Development Test Run

make local_run

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ‘จโ€๐Ÿ’ป Author

Adam Zhou - jianzhou42@163.com


โญ If this project helps you, please give it a star!

About

ไธ€ไธชๅŸบไบŽๅคง่ฏญ่จ€ๆจกๅž‹็š„ๆ™บ่ƒฝๆ’ญๅฎขๅˆถไฝœๅทฅๅ…ท๏ผŒ่ƒฝๅคŸ่‡ชๅŠจ็”Ÿๆˆๆ’ญๅฎขๆ—ถ้—ด็บฟๅ’Œๅฏน่ฏๅ†…ๅฎน๏ผŒๆ”ฏๆŒ่‡ชๆˆ‘ๅๆ€ๆœบๅˆถ็กฎไฟ้ซ˜่ดจ้‡ๅ†…ๅฎน่พ“ๅ‡บใ€‚

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors