Skip to main content

podgenai

podgenai is a Python 3.14 application to generate an informational single-speaker or two-speaker audiobook/podcast mp3 file on a given topic using an OpenAI LLM. The material is generated from the model's internal knowledge or otherwise from a given markdown source document. Web search or other sources are not used. The output file is generated as a series of sections, each covering a subtopic of the given topic. A funded OpenAI API key is required.

The loosely targeted duration of the generated file is an hour, although comprehensive coverage often results in a multi-hour duration by default. A smaller duration can in practice be enforced by limiting the number of sections to as few as three, although this is expected to result in less comprehensive coverage of the topic. For a hypothetical ten hour podcast, the heuristic for its cost is $10 USD, with much of this cost being for the TTS generation, with a smaller duration costing proportionally less.

Caption Link
Repo https://github.com/impredicative/podgenai
Changelog https://github.com/impredicative/podgenai/releases
Package https://pypi.org/project/podgenai
Podcast https://open.spotify.com/show/0WayD9YdeSTxcfm63lnam5
Podcast RSS https://anchor.fm/s/f4868644/podcast/rss

Approach

For a given topic, the high-level generation approach is as follows:

  1. Applicable subtopics are listed using the LLM. If, however, the topic is unknown to the LLM or is not supported by a given source document, the process is aborted with an explanatory error.
  2. The required voice or voices are selected using the LLM from the configured choices. For a monologue, a single voice is selected; for a duologue, a male and a female voice are selected.
  3. Concurrently for each subtopic, the corresponding monologue text is generated using the LLM. If a source document was provided, it is used for each generation.
  4. The monologue texts are deduplicated to remove substantive repetition across adjacent subtopics. This is done concurrently while avoiding information loss by using a red-black odd-even approach. It is observed to decrease the total text length by 6-40%.
  5. For a duologue, concurrently for each subtopic, the corresponding duologue text and tone instructions are generated using the LLM from the subtopic's monologue text.
  6. Speech is generated using text-to-speech (TTS), either concurrently for each subtopic in a monologue, or concurrently for each line in a duologue.
  7. The speech files are concatenated using ffmpeg, with appropriate pauses added between parts and subtopics, as well as between lines for a duologue.

Explicit cache breakpoints are used across all LLM calls to optimize input token costs.

Models used

  • Knowledge model (gpt-6.1-sol) is used for:
    • listing subtopics
    • voice selection
    • monologue text generation if the episode is to be created from the model's internal knowledge
    • duologue text generation
  • Text model (gpt-6.1-sol) is used for:
    • monologue text generation if the episode is to be created from a given source document
    • monologue text deduplication
  • Text-to-speech model (gpt-4o-mini-tts-2025-12-15) is used for:
    • speech generation

Samples

These generated mp3 files are available for download:

Type Voice(s) Name Links
two-speaker from model modern-female (marin), modern-male (cedar) Sinusitis Mega, Spotify
two-speaker from source modern-female (marin), modern-male (cedar) Indigo light for myopia prevention Mega, Spotify

There also is a related podcast (RSS) to which episodes may be posted over time.

A playback speed of 1.05x is recommended for non-technical topics, 1.0x for technical topics, and 0.95x for foreign language topics.

Setup

Common setup

  • In the working directory, create a file named .env, with the intended environment variable OPENAI_API_KEY=<your OpenAI API key>, or set it in a different way.
  • In .env, optionally also set the environment variable PODGENAI_OPENAI_MAX_WORKERS=32 for faster generation, with its default value being 16.
  • Ensure that ffmpeg and ffprobe are available. This is automatic if using the included devcontainer definition.
  • Continue the setup via GitHub or PyPI as below.
  • Continue from the common setup steps.
  • Clone or download this repo.
  • Build and provision the defined devcontainer.

Setup via GitHub manually

  • Continue from the common setup steps.
  • Clone or download this repo.
  • Ensure that uv is installed and available.
  • In the repo directory, run uv sync --locked to set up the environment. Alternatively, run ./scripts/setup_uv.sh to both install uv and run the sync command.

Setup via PyPI

  • Continue from the common setup steps.
  • Create and activate a Python 3.14 devcontainer or virtual environment.
  • Install via PyPI: pip install -U podgenai or uv add -U podgenai or uv pip install -U podgenai.

Usage

Usage can be as a command-line application or as a Python library. By default, the generated mp3 file will be written to the current working directory.

Usage tips

  • If a requested topic fails to generate subtopics due to a refusal, retry up to a few times, as it may succeed with several attempts. If it doesn't, try rewording it, perhaps to be broader or narrower or more factual. Up to two attempts are made per run, although the first attempt will reuse the disk cache if available.
  • To control the resulting duration, specify the target number of covered subtopics using the --max-sections (-s) option.
  • To switch from the default two-speaker generation to single-speaker generation, use the --speakers (-k) option.
  • To optionally generate a cover art image for your topic, this custom GPT or the Podcast episode cover art skill can be used.
  • To attempt generation in a foreign language, specify the title in the desired language along with a parenthesized prefix of the language name, e.g. "México (Español)". If the generation is refused the first time, try again. Also refer to and use the --no-markers (-nm) option.

Source document usage

It is not necessary to provide a source document for common topics because the LLM has considerable internal knowledge of them. If a source document is to be used, it must be a text or markdown file specified using the --document (-d) option. It is suggested that the source document be a detailed report on the topic.

Multiple source documents are not supported, but can first be consolidated by an LLM into a single document. A binary file such as PDF or DOCX is not supported either, but can first be converted to markdown using a tool or an LLM.

The following AI skills can be used to prepare a compatible source document:

Usage as application

Usage help is copied below:

$ podgenai -h
Usage: podgenai [OPTIONS]

  Generate and write an audiobook podcast mp3 file for the given topic to the given output file path.

Options:
  -t, --topic TEXT                Topic. If not given, the user is prompted for it.
  -p, --path PATH                 Output file or directory path. If an intended file path, it must have an ".mp3"
                                  suffix. If a directory, it must exist, and the file name is auto-determined. If not
                                  given, the output file is written to the current working directory with an auto-
                                  determined file name.
  -d, --document PATH             Path to a single text or markdown document file to use as the exclusive source for
                                  the podcast. If not given, the podcast is generated from the model's internal
                                  knowledge.
  -s, --max-sections INTEGER RANGE
                                  Maximum number of sections, between 3 and 100. If not given, it is unrestricted.
                                  [3<=x<=100]
  -k, --speakers INTEGER RANGE    Number of speakers, either 1 or 2. If not given, it is 2.  [1<=x<=2]
  -m, --markers / -nm, --no-markers
                                  Include markers at the start or end of sections in the generated audio. If
                                  `--markers`, markers are included, and this is the default. If `--no-markers`,
                                  markers are excluded, as can be appropriate for foreign-language generation.
  -c, --confirm / -nc, --no-confirm
                                  Confirm before full-text and speech generation. If `--confirm`, a confirmation is
                                  interactively sought as each step of the workflow progresses, and this is the
                                  default. If `--no-confirm`, the full-text and speech are generated without
                                  confirmations.
  -h, --help                      Show this message and exit.

Usage examples:

$ podgenai -t "The Quest for Infinity"

$ podgenai -t "The Quest for Infinity" -p ~/Documents/

$ podgenai -t "The Quest for Infinity" -p ~/Documents/output.mp3 -nc

$ podgenai -t "The Quest for Infinity" -s 3 -k 1

# podgenai -t "The Quest for Infinity" -d ~/Downloads/deep-research_report.md

$ podgenai -t "La Quête de l’infini (Français)" -nm

Usage as library

>>> from podgenai import generate_media
>>> help(generate_media)
Help on function generate_media in module podgenai.podgenai:

generate_media(
    topic: str,
    *,
    output_path: Path | None = None,
    document: str | None = None,
    max_sections: int | None = None,
    speakers: int = 2,
    markers: bool = True,
    confirm: bool = False
) -> Path
    Return the output path after generating and writing an audiobook podcast to file for the given topic.

    Params:
    * `topic`: Topic.
    * `output_path`: Output file or directory path.
        If an intended file path, it must have an ".mp3" suffix. If a directory, it must exist, and the file name is auto-determined.
        If not given, the output file is written to the repo directory with an auto-determined file name.
    * `document`: Contents of a single text or markdown document to use as the exclusive source for the podcast.
        If not given, the podcast is generated from the model's internal knowledge.
    * `max_sections`: Maximum number of sections to generate. It is between 3 and 100. It is unrestricted if not given.
    * `speakers`: Number of speakers, either 1 or 2. Its default is 2.
    * `markers`: Include markers at the start or end of sections in the generated audio.
        If true, markers are included. If false, markers are excluded, as can be appropriate for foreign-language generation. Its default is true.
    * `confirm`: Confirm before full-text and speech generation.
        If true, a confirmation is interactively sought after generating and printing the list of subtopics, before generating the full-text, and also before generating the speech. Its default is false.

    If failed, a subclass of the `podgenai.exceptions.Error` exception is raised.

Cache

Text and speech segments are cached locally on disk in the ./work/<topic> directory. They can manually and selectively be deleted. This deletion is not automatic. Moreover, it is necessary to delete one or more applicable cached files to force a regeneration, although a change of runtime settings forces it as well, as do routine updates to the software.

Disclaimer

This software is provided "as is," without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.

Users should be aware that both the text and the audio of the generated files are produced by artificial intelligence (AI) based on the inputs given and the data available to the AI model at the time of generation. As such, inaccuracies, errors, or unintended content may occur. Users are advised to exercise caution and verify the accuracy and appropriateness of the generated content before any use or reliance.

You are responsible for the costs associated with the use of the OpenAI API as required by the software, and you must comply with the OpenAI API terms of service. The software's functionality is dependent on the availability and functionality of external services and software, including but not limited to the OpenAI API and ffmpeg, over which the authors have no control.

The use of the OpenAI API key and any generated content must comply with all applicable laws and regulations, including copyright laws and the terms of service of the OpenAI platform. You are solely responsible for ensuring that your use of the software and any generated content complies with the OpenAI terms of service and any other applicable laws and regulations.

This software is licensed under the GNU Lesser General Public License (LGPL), which allows for both private and commercial use, modification, and distribution, subject to the terms and conditions set forth in the LGPL. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.

The authors do not claim ownership of any content generated using this software. Responsibility for the use of any and all generated content rests with the user. Users should exercise caution and due diligence to ensure that generated content does not infringe on the rights of third parties.

This disclaimer is subject to change without notice. It is your responsibility to review it periodically for updates.

Metadata

Release files for podgenai 0.25.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for podgenai 0.25.0
File Size Uploaded
podgenai-0.25.0.tar.gz 47.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for podgenai 0.25.0
File Interpreter ABI Platform
podgenai-0.25.0-py3-none-any.whl Python 3 none any Details

Total release size: 108.6 kB

Release files / podgenai-0.25.0.tar.gz

Download URL podgenai-0.25.0.tar.gz
Size 47.9 kB
Tags Source
SHA-256 checksum
How to use checksums
837a090c232fe347db641cd63e3f89bab52e33d67bb27b50acbf0e17d30c388f
BLAKE2b-256 checksum
How to use checksums
8171c9a59f96218b06fee03a5583e29676c99a08470c5f9106ef3a22918a45d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / podgenai-0.25.0-py3-none-any.whl

Download URL podgenai-0.25.0-py3-none-any.whl
Size 60.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d12a7bd2a4f4ad983774f7f4cf76e32b975a8365803f8d864ba3b93ec3bb1b8
BLAKE2b-256 checksum
How to use checksums
e570baa88272daf83961f09a9ea9fcc6761ad0118d1829af1d726a4d36c8b5e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.26.1

2 release files

0.26.0

2 release files

This release

0.25.0 This release

2 release files

0.24.0

2 release files

0.23.0

2 release files

0.22.0

2 release files

0.21.2

2 release files

0.21.1

2 release files

0.21.0

2 release files

0.20.0

2 release files

0.19.0

2 release files

0.18.0

2 release files

0.17.2

2 release files

0.17.1

2 release files

0.17.0

2 release files

0.15.2

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.1.5

2 release files

0.1.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page