# Introduction

The `okcourse` Python library uses AI to generate audiobook-style courses in MP3 format with lectures on any topic.

<div class="grid cards" markdown>
- :material-clock-fast: [Get started](./get-started.md)
- :simple-python: [API reference](reference/index.md)
- :octicons-file-code-16: [Example apps](./examples/index.md)
- :material-map: [Roadmap](./roadmap.md)
<!-- - :octicons-versions-16: [Library `CHANGELOG`](./changelog.md) -->
</div>

Given a course topic of your choosing, the `okcourse` library handles all the prompting and API interaction required to:

- Generate a **course outline** and **lecture text** with an LLM
- Create **cover image** for the course by using an image model
- Produce an **audio file** from the lecture text using a text-to-speech (TTS) model

Here's that workflow in code:

```python
--8<-- "examples/snippets/async_openai_custom_settings.py:openaiasyncgenerator_custom_settings"
```
{.annotate}

1. Generate a [`Course`][okcourse.models.Course] on any topic that doesn't run afoul of the AI service provider's content policy.
2. Lectures form the core content of a course. More lectures means longer courses.
3. If the AI service provider supports it, you can specify which voice to use for the lecture audio.
4. This is where the course audio file (MP3), its cover image (PNG), and log file(s) are saved. All are optional.
5. Coures generators use an AI service provider's API to generate course content. OpenAI is the first supported provider.
6. The course outline defines the structure of the course and includes the titles and subtopics of its lectures.
7. Based on the course outline, this method populates the text of each lecture in the course.
8. To have AI generate album art for the audio file, call `generate_image()` before you generate the audio file (next line).
9. This is the final step in the course generation process. It creates an MP3 file of the course's lectures read aloud by an AI-generated voice.
10. The [`Course`][okcourse.models.Course] and many of its attributes are [Pydantic models](https://docs.pydantic.dev/), making them easier to serialize, deserialize, and work with in general.

## Course audio in MP3

Feed nearly any catchy title to `okcourse` and you can fire up the course audio in your favorite media player in minutes. (1)
{.annotate}

Curious about propulsion systems for interstellar space travel?

1. Durations vary, but `okcourse` can generate a **1.5-hour** audio course with 20 lectures in about **2.5 minutes** with OpenAI's `gpt-4o` and `tts-1` models.

![Screenshot of Plex web player displaying an audio lecture titled 'Interstellar Space Travel: Propulsion Systems from Factual to Fantastical' by Fable @ OpenAI, showing a retro-styled cover illustration of a futuristic spacecraft and technical diagrams with a playback position of 32:18 out of 49:29.](images/plex-01-interstellar.png)

## OK for entertainment

The courses generated by the AI models and assembled by this library aren't exactly [The Great Courses](https://www.thegreatcourses.com/). They're fine for familiarizing yourself with a topic or for pure entertainment, but as with any AI-generated content, you should question and verify rather than assume unbiased accuracy.

## Thanks

Inspirations for `okcourse` were [The Great Courses](https://www.thegreatcourses.com/) and cool projects like [podgenai](https://github.com/impredicative/podgenai) and [tts-joinery](https://github.com/drien/tts-joinery).
