Skip to content

armanjscript/AI-Podcast-Generator-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽ™๏ธ AI Podcast Generator Bot

Transform any topic into a podcast-style audio episode โ€” powered by LangGraph, NVIDIA LLM, and Pocket TTS.

Python 3.10+ LangGraph Streamlit License: MIT


๐Ÿ“– Table of Contents


๐ŸŒŸ Overview

AI Podcast Generator Bot is an intelligent system that converts user queries into fully produced podcast-style audio content. It leverages a multi-phase LangGraph workflow that researches topics via web search, summarizes findings with an LLM, evaluates content relevance, and synthesizes natural-sounding speech โ€” all through a clean Streamlit interface.

Simply type a topic or question, and the bot will:

  1. Extract the core topic and language from your query
  2. Research the topic by searching the web for relevant articles
  3. Summarize the findings into a structured, podcast-ready script
  4. Evaluate the relevance of the generated content to your original query
  5. Refine and repeat if the content doesn't meet the quality threshold
  6. Synthesize the final script into a downloadable WAV audio file

๐Ÿ—๏ธ Architecture

graph TB
    subgraph "User Interface Layer"
        UI[Streamlit Web UI]
    end

    subgraph "Workflow Orchestration Layer"
        WG[LangGraph StateGraph]
        P1[Phase 1: Query Extraction]
        P2[Phase 2: Content Generation]
        P3[Phase 3: Relevance Evaluation]
        TTS[Phase 4: Audio Synthesis]
        RQ[Query Refinement Loop]
    end

    subgraph "Service Layer"
        LLM[NVIDIA LLM Service]
        TAV[Tavily Web Search]
        PTTS[Pocket TTS Engine]
    end

    subgraph "Data Layer"
        MOD[Pydantic Models]
        HL[Helper Utilities]
    end

    UI --> WG
    WG --> P1
    WG --> P2
    WG --> P3
    WG --> TTS
    WG --> RQ

    P1 --> LLM
    P2 --> TAV
    P2 --> LLM
    P3 --> LLM
    TTS --> PTTS
    RQ --> LLM

    P1 --> MOD
    P3 --> MOD
    RQ --> MOD
    TTS --> HL
Loading

๐Ÿ”„ Workflow Pipeline

The core of the application is a LangGraph StateGraph that orchestrates a multi-phase pipeline with conditional branching and iterative refinement.

flowchart TD
    START([User Query]) --> P1

    subgraph "Phase 1 โ€” Query Extraction"
        P1[๐Ÿ” Extract Topic & Language]
    end

    P1 --> P2

    subgraph "Phase 2 โ€” Content Generation"
        P2[๐ŸŒ Search Web via Tavily\n๐Ÿ“ Summarize Articles via LLM]
    end

    P2 --> P3

    subgraph "Phase 3 โ€” Relevance Check"
        P3[โš–๏ธ Score Relevance 0.0 โ€“ 1.0]
    end

    P3 -->|Score >= 0.8| TTS
    P3 -->|Score < 0.8| RQ

    subgraph "Query Refinement"
        RQ[๐Ÿ”„ Refine Query with LLM]
    end

    RQ -->|Iterations < 3| P1
    RQ -->|Iterations >= 3| TTS

    subgraph "Phase 4 โ€” Audio Synthesis"
        TTS[๐Ÿ”Š Generate Speech via Pocket TTS]
    end

    TTS --> END([Downloadable WAV Audio])

    style P1 fill:#4FC3F7,stroke:#0288D1,color:#000
    style P2 fill:#81C784,stroke:#388E3C,color:#000
    style P3 fill:#FFB74D,stroke:#F57C00,color:#000
    style TTS fill:#E57373,stroke:#D32F2F,color:#fff
    style RQ fill:#CE93D8,stroke:#7B1FA2,color:#000
    style END fill:#A5D6A7,stroke:#2E7D32,color:#000
Loading

Decision Logic

Condition Action
Relevance score โ‰ฅ 0.8 Proceed to TTS audio generation
Relevance score < 0.8 and iterations < 3 Refine query and restart from Phase 1
Iterations โ‰ฅ 3 (quality gate) Force-proceed to TTS to prevent infinite loops

โœจ Features

  • Natural Language Input โ€” Type any question or topic in plain language; the system extracts the core subject and language automatically
  • Real-Time Web Research โ€” Uses Tavily's advanced search to fetch up-to-date, relevant articles from the web
  • LLM-Powered Summarization โ€” Condenses multiple articles into a structured, podcast-ready narrative with headings, key points, and a conclusion
  • Quality Gate with Auto-Refinement โ€” An editorial review phase scores content relevance; if the score is below 0.8, the query is automatically refined and the pipeline restarts (up to 3 iterations)
  • Multi-Language TTS โ€” Supports English, French, German, Spanish, Italian, and Portuguese with dedicated voice profiles
  • Interactive Web UI โ€” Built with Streamlit for a seamless, browser-based experience with audio playback and one-click download
  • Structured Output โ€” Uses Pydantic models for type-safe, predictable LLM responses throughout the pipeline

๐Ÿ› ๏ธ Tech Stack

Component Technology Purpose
UI Framework Streamlit 1.30+ Interactive web interface
Workflow Engine LangGraph 0.2+ Stateful multi-phase orchestration
LLM Provider NVIDIA NIM via LangChain Query extraction, summarization, scoring, refinement
Web Search Tavily 0.5+ Real-time article retrieval
Text-to-Speech Pocket TTS 0.1+ Neural speech synthesis
Data Validation Pydantic 2.0+ Structured LLM output parsing
Audio I/O SciPy 1.11+ WAV file writing
Python 3.10+ Runtime environment

๐Ÿ“ Project Structure

AI-Podcast-Generator-Bot/
โ”œโ”€โ”€ main.py                          # Application entry point
โ”œโ”€โ”€ pyproject.toml                   # Project metadata and dependencies (PEP 621)
โ”œโ”€โ”€ requirements.txt                 # Pip-compatible dependency list
โ”œโ”€โ”€ README.md                        # This file
โ””โ”€โ”€ app/
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ models/
    โ”‚   โ”œโ”€โ”€ __init__.py
    โ”‚   โ””โ”€โ”€ query.py                 # Pydantic data models
    โ”œโ”€โ”€ services/
    โ”‚   โ”œโ”€โ”€ __init__.py
    โ”‚   โ”œโ”€โ”€ llm_service.py           # NVIDIA LLM integration (LangChain)
    โ”‚   โ”œโ”€โ”€ tavily_service.py        # Tavily web search client
    โ”‚   โ””โ”€โ”€ tts_service.py           # Pocket TTS audio synthesis
    โ”œโ”€โ”€ workflow/
    โ”‚   โ”œโ”€โ”€ __init__.py
    โ”‚   โ””โ”€โ”€ podcast_workflow.py      # LangGraph state machine & pipeline
    โ”œโ”€โ”€ ui/
    โ”‚   โ”œโ”€โ”€ __init__.py
    โ”‚   โ””โ”€โ”€ streamlit_app.py         # Streamlit frontend
    โ””โ”€โ”€ utils/
        โ”œโ”€โ”€ __init__.py
        โ””โ”€โ”€ helpers.py               # Audio base64 encoding utility

๐Ÿ“‹ Prerequisites

Before getting started, make sure you have the following:

Prerequisite Details
Python Version 3.10 or higher
NVIDIA API Key Obtain from build.nvidia.com โ€” used for LLM inference
Tavily API Key Obtain from tavily.com โ€” used for web search

๐Ÿš€ Installation

1. Clone the Repository

git clone https://github.com/armanjscript/AI-Podcast-Generator-Bot.git
cd AI-Podcast-Generator-Bot

2. Create a Virtual Environment

python -m venv venv
source venv/bin/activate      # Linux / macOS
# venv\Scripts\activate       # Windows

3. Install Dependencies

pip install -r requirements.txt

โš™๏ธ Configuration

The application requires two API keys, which can be provided in two ways:

Option A: Via the Streamlit UI (Recommended)

Launch the app and enter your keys in the sidebar under API Configuration. They will be stored in the session state for the duration of your session.

Option B: Via Environment Variables

Create a .env file in the project root:

NVIDIA_API_KEY=your_nvidia_api_key_here
TAVILY_API_KEY=your_tavily_api_key_here

Then load them in your shell:

export $(grep -v '^#' .env | xargs)

๐ŸŽฌ Usage

Start the Streamlit application:

streamlit run main.py

The app will open in your browser (typically at http://localhost:8501). From there:

  1. Enter your API keys in the sidebar and click Register API Keys
  2. Type your topic or question in the text area (e.g., "Tell me about the latest developments in AI technology")
  3. Click "Generate Podcast" and wait for the pipeline to complete
  4. Review the generated content summary, relevance score, and topic/language extraction
  5. Listen to the audio directly in the browser or download the .wav file

๐Ÿ” How It Works

Phase 1 โ€” Query Extraction

The user's natural language input is passed to the NVIDIA LLM with structured output parsing. The LLM extracts two key pieces of information:

  • Topic: The core subject of the query
  • Language: The desired output language (defaults to the user's input language if not specified)

These are captured in a UserQueryExtraction Pydantic model for type safety.

Phase 2 โ€” Content Generation

The extracted topic is used to perform an advanced web search via the Tavily API, retrieving up to 5 relevant articles with full content. The articles are then passed to the LLM, which generates a well-structured markdown summary containing:

  • A main title
  • An introduction section
  • Key points from each article
  • A conclusion

The summary is generated in the user's requested language.

Phase 3 โ€” Relevance Evaluation

The generated summary is evaluated by the LLM, which assigns a relevance score between 0.0 and 1.0 based on how well the content aligns with the original topic. This acts as an editorial quality gate:

  • Score โ‰ฅ 0.8 โ†’ Content is relevant enough; proceed to audio synthesis
  • Score < 0.8 โ†’ Content needs improvement; the query is refined and the pipeline restarts

To prevent infinite loops, the system tracks iteration count and forces TTS generation after 3 iterations regardless of the score.

Phase 4 โ€” Audio Synthesis

The approved summary text is converted to speech using Pocket TTS, a neural text-to-speech model. The system automatically selects a voice profile based on the detected language, generates the audio waveform, and saves it as a .wav file using SciPy's wavfile module.


๐Ÿ“ Data Models

The application uses Pydantic v2 models for structured, validated LLM outputs:

classDiagram
    class UserQueryExtraction {
        +str topic
        +str language
    }

    class BinaryScore {
        +float relevance_score  [0.0, 1.0]
    }

    class QueryRefinement {
        +str sentence
    }

    class PodcastState {
        +str user_query
        +str nvidia_api_key
        +str tavily_api_key
        +str topic
        +str language
        +list articles
        +str summarized_content
        +float relevance_score
        +str refined_query
        +str audio_path
        +int iteration_count
    }

    UserQueryExtraction --> PodcastState : used in Phase 1
    BinaryScore --> PodcastState : used in Phase 3
    QueryRefinement --> PodcastState : used in Refinement
Loading
Model Fields Used In
UserQueryExtraction topic: str, language: str Phase 1 โ€” Query parsing
BinaryScore relevance_score: float (0.0โ€“1.0) Phase 3 โ€” Relevance evaluation
QueryRefinement sentence: str Refinement loop โ€” Query rewriting
PodcastState 11 fields (see diagram) LangGraph state โ€” carries data across all phases

๐Ÿ—ฃ๏ธ Voice Mapping

Pocket TTS provides distinct voice profiles for different languages. The system automatically selects the appropriate voice based on the detected language:

Language Voice Name Description
๐Ÿ‡ฌ๐Ÿ‡ง English alba Default English female voice
๐Ÿ‡ซ๐Ÿ‡ท French estelle French female voice
๐Ÿ‡ฉ๐Ÿ‡ช German juergen German male voice
๐Ÿ‡ช๐Ÿ‡ธ Spanish lola Spanish female voice
๐Ÿ‡ฎ๐Ÿ‡น Italian giovanni Italian male voice
๐Ÿ‡ต๐Ÿ‡น Portuguese rafael Portuguese male voice

Note: If the detected language is not in the mapping, the system defaults to alba (English).


๐Ÿ“„ License

This project is licensed under the MIT License.


Built with โค๏ธ using LangGraph, NVIDIA NIM, Tavily, and Pocket TTS

About

The Bot gets your query, extracting the appropriate topic and language, searching the 5 latest articles on internet, summarizing them and generating the podcast for downloading

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages