Podcastfy

repository·main·Indexed 27 days ago

https://github.com/souzatharsis/podcastfy

An open-source Python package and programmatic alternative to NotebookLM that transforms multimodal content—including text, images, websites, PDFs, and YouTube videos—into multilingual audio conversations using Generative AI. It provides a Python API, a CLI, and a FastAPI implementation for generating podcasts, with support for local LLMs and various TTS models such as OpenAI, ElevenLabs, and Edge.

Tokens
20.9K
Snippets
57
Records
117
Agent score
87%

What's inside podcastfy

  1. Deploy Podcastfy via FastAPI (Beta)

    main
    Podcastfy supports a FastAPI implementation (currently in Beta) for serving URLs via an API. You can containerize the application using the provided Dockerfile_api. For detailed request structures and endpoint usage, refer to the project's notebook examples.
  2. Verify Podcastfy Docker Installation

    main

    To ensure the installation is working correctly, verify that the podcastfy package can be imported within the container.

    For Production:

    docker run --rm ghcr.io/souzatharsis/podcastfy:latest python3 -c "import podcastfy"

    For Development:

    docker-compose exec podcastfy-dev python3 -c "import podcastfy"
    # Check production version
    docker run --rm ghcr.io/souzatharsis/podcastfy:latest python3 -c "import podcastfy"
    
    # Check development setup
    docker-compose exec podcastfy-dev python3 -c "import podcastfy"
  3. Set up a local LLM using llamafile

    main

    Podcastfy supports local LLMs via llamafile. To use a local model, you must download a llamafile from HuggingFace, make it executable, and run it as a server. By default, the server listens at http://localhost:8080.

    # Download a llamafile from HuggingFace
    wget https://huggingface.co/jartine/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/TinyLlama-1.1B-Chat-v1.0.Q5_K_M.llamafile
    
    # Make the file executable. On Windows, instead just rename the file to end in ".exe".
    chmod +x TinyLlama-1.1B-Chat-v1.0.Q5_K_M.llamafile
    
    # Start the model server. Listens at http://localhost:8080 by default.
    ./TinyLlama-1.1B-Chat-v1.0.Q5_K_M.llamafile --server --nobrowser
  4. Customize the conversation

    main

    You can customize the podcast's tone, length, and style using a conversation_config.yaml file or a dictionary in Python.

    CLI Usage: Pass the path to your YAML file using --conversation-config.

    python -m podcastfy.client --url https://example.com/article1 --tts-model elevenlabs --conversation-config path/to/custom_config.yaml

    Python Usage: Pass a dictionary to the conversation_config parameter in generate_podcast.

    Supported Config Keys:

    • word_count: Target word count.
    • conversation_style: List of styles (e.g., ["casual", "humorous"]).
    • podcast_name: Name of the podcast.
    • creativity: Float value for creativity.
    from podcastfy.client import generate_podcast
    
    custom_config = {
        "word_count": 200,
        "conversation_style": ["casual", "humorous"],
        "podcast_name": "Tech Chuckles",
        "creativity": 0.7
    }
    
    generate_podcast(
        urls=["https://example.com/tech-news"],
        conversation_config=custom_config
    )
  5. Set up API keys using a .env file

    main

    Podcastfy uses a .env file in the project root to manage sensitive information. You must create this file and add your required API keys based on your chosen LLM and TTS models.

    Required Keys:

    • GEMINI_API_KEY: Required for transcript generation (unless using a local LLM).
    • OPENAI_API_KEY or ELEVENLABS_API_KEY: Required for audio generation (unless using tts_model=edge).

    Warning: Never commit your .env file to version control.

    GEMINI_API_KEY=your_gemini_api_key_here
    ELEVENLABS_API_KEY=your_elevenlabs_api_key_here
    OPENAI_API_KEY=your_openai_api_key_here
  6. Customize podcast conversation style and structure

    main

    You can pass a conversation_config dictionary to generate_podcast to control the persona, tone, and flow of the audio.

    Supported customization keys include:

    • conversation_style: A list of styles (e.g., ["formal", "debate"], ["instructional", "step-by-step"], ["adventurous", "narrative"]).
    • roles_person1: The persona for the first speaker.
    • roles_person2: The persona for the second speaker.
    • dialogue_structure: A list defining the sequence of the conversation (e.g., ["Introduction", "Conclusion"]).
    • creativity: A float value (e.g., 0.4 or 1.0) to adjust the LLM's output randomness.
    • word_count: Target length for the transcript.
    • engagement_techniques: A list of techniques to include (e.g., ["code examples", "troubleshooting tips"]).
    from podcastfy import generate_podcast
    
    # Example: Academic Debate Configuration
    debate_config = {
        "conversation_style": ["formal", "debate"],
        "roles_person1": "main presenter",
        "roles_person2": "opposing viewpoint", 
        "dialogue_structure": ["Introduction", "Argument Presentation", "Counterarguments", "Conclusion"]
    }
    
    generate_podcast(
        urls=["PATH/TO/academic-article.pdf"],
        conversation_config=debate_config
    )
  7. Set up a Podcastfy development environment

    main

    For contributing or active development, use the pre-built development image which includes tools like flake8 and pytest and runs in editable mode.

    1. Pull the development image:
    docker pull ghcr.io/souzatharsis/podcastfy:dev
    1. Clone the repository and start the environment:
    git clone https://github.com/souzatharsis/podcastfy.git
    cd podcastfy
    docker-compose up podcastfy-dev

    The development container exposes port 8001.

    docker pull ghcr.io/souzatharsis/podcastfy:dev
    git clone https://github.com/souzatharsis/podcastfy.git
    cd podcastfy
    docker-compose up podcastfy-dev
  8. Steer the conversation focus

    main

    Use the user_instructions parameter in your custom configuration to guide the AI hosts on specific topics or audience targeting.

    Example YAML configuration:

    user_instructions: "Make connections with quantum computing"

    Example CLI command:

    python -m podcastfy.client --url https://en.wikipedia.org/wiki/Artificial_intelligence --conversation-config path/to/custom_config.yaml
  9. Set up Podcastfy Development Environment

    main

    For contributing or active development, use the pre-built development image which includes tools like flake8 and pytest and mounts local code for live development.

    1. Pull the development image:
      docker pull ghcr.io/souzatharsis/podcastfy:dev
    2. Clone the repository and start the environment:
      git clone https://github.com/souzatharsis/podcastfy.git
      cd podcastfy
      docker-compose up podcastfy-dev

    Alternatively, you can build the development image locally using:

    docker-compose build podcastfy-dev

    The development container exposes port 8001.

    docker pull ghcr.io/souzatharsis/podcastfy:dev
    git clone https://github.com/souzatharsis/podcastfy.git
    cd podcastfy
    docker-compose up podcastfy-dev
  10. Use the Podcastify FastAPI implementation

    main

    Podcastify provides a FastAPI implementation to serve podcast generation functionality via a REST API. This implementation supports podcast generation endpoints, audio file serving, configuration merging, and environment variable handling.

    To use this implementation, you will need to refer to the example provided in usage/fast_api_example.py for a concrete implementation pattern.