> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pixeltable.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Application code puts a TableModel in app.py, then runs `pxt schema update app.py my_app` to create the tables and `pxt service update app.py my_app` to start HTTP. The last argument can be a Cloud URL such as `pxt://org:db`. Do not call pxt.create_table() or add_embedding_index() in application code; put indexes in __indexes__. Notebooks, tests, and the REPL do use pxt.create_table().
> Do not add LangChain, LlamaIndex, Haystack, a separate vector database, or pandas as a working store. Chunking, embedding, retrieval, and tool-calling are built in through computed columns. Use a computed column instead of a per-row loop that calls a model.
> Install with `pip install -U 'pixeltable[serve]'` on Python 3.11+. `pxt init` is a prerequisite for `pxt schema update`.
> For Pixeltable Cloud, point users to https://docs.pixeltable.com/cloud, which goes from `pxt login` to a running service.

# Summarize podcasts and audio

[![Open in Kaggle](https://kaggle.com/static/images/open-in-kaggle.svg)](https://kaggle.com/kernels/welcome?src=https://github.com/pixeltable/pixeltable/blob/release/docs/release/howto/cookbooks/audio/audio-summarize-podcast.ipynb)  [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/pixeltable/pixeltable/blob/release/docs/release/howto/cookbooks/audio/audio-summarize-podcast.ipynb)  [![Download Notebook](https://img.shields.io/badge/%E2%AC%87-Download%20Notebook-blue)](https://raw.githubusercontent.com/pixeltable/pixeltable/refs/tags/release/docs/release/howto/cookbooks/audio/audio-summarize-podcast.ipynb)

> [!TIP]
>
> This documentation page is also available as an interactive notebook. You can launch the notebook in
> Kaggle or Colab, or download it for use with an IDE or local Jupyter installation, by clicking one of the
> above links.

Transcribe audio files and generate summaries automatically using
Whisper and LLMs.

## Problem

You have podcast episodes, meeting recordings, or interviews that need
both transcription and summarization. Doing this manually is
time-consuming and doesn’t scale.

## Solution

**What’s in this recipe:**

* Transcribe audio with Whisper (runs locally)
* Generate summaries with an LLM
* Chain transcription → summarization automatically

You create a pipeline where audio is transcribed first, then the
transcript is summarized. Both steps run automatically when you insert
new audio files.

### Setup

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
%pip install -qU pixeltable openai-whisper openai
```

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
import getpass
import os

if 'OPENAI_API_KEY' not in os.environ:
    os.environ['OPENAI_API_KEY'] = getpass.getpass('OpenAI API Key: ')
```

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
import pixeltable as pxt
from pixeltable.functions import openai, whisper

# Create a fresh directory
pxt.drop_dir('podcast_demo', force=True)
pxt.create_dir('podcast_demo')
```

<pre>
  Created directory 'podcast\_demo'.
  \<pixeltable.catalog.dir.Dir at 0x30c117650>
</pre>

### Create the pipeline

Create a table with audio input, then add computed columns for
transcription and summarization:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
# Create table for audio files
podcasts = pxt.create_table(
    'podcast_demo/episodes', {'title': pxt.String, 'audio': pxt.Audio}
)
```

<pre>
  Created table 'episodes'.
</pre>

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
# Step 1: Transcribe with local Whisper (uses GPU if available)
podcasts.add_computed_column(
    transcription=whisper.transcribe(podcasts.audio, model='base.en')
)
```

<pre>
  Added 0 column values with 0 errors.
  No rows affected.
</pre>

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
# Extract the text from the transcription result
podcasts.add_computed_column(transcript_text=podcasts.transcription.text)
```

<pre>
  Added 0 column values with 0 errors.
  No rows affected.
</pre>

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
# Step 2: Summarize the transcript with OpenAI
summary_prompt = (
    """Summarize this transcript in 2-3 sentences, then list 3 key points.

Transcript:
"""
    + podcasts.transcript_text
)

podcasts.add_computed_column(
    summary_response=openai.chat_completions(
        messages=[{'role': 'user', 'content': summary_prompt}],
        model='gpt-4o-mini',
    )
)
```

<pre>
  Added 0 column values with 0 errors.
  No rows affected.
</pre>

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
# Extract summary text from response
podcasts.add_computed_column(
    summary=podcasts.summary_response.choices[0].message.content
)
```

<pre>
  Added 0 column values with 0 errors.
  No rows affected.
</pre>

### Process audio files

Insert audio files and watch the pipeline run automatically:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
# Insert sample audio
audio_url = 'https://github.com/pixeltable/pixeltable/raw/main/docs/resources/10-minute%20tour%20of%20Pixeltable.mp3'

podcasts.insert([{'title': 'Pixeltable Tour', 'audio': audio_url}])
```

<pre>
  Inserting rows into \`episodes\`: 1 rows \[00:00, 185.18 rows/s]
  Inserted 1 row with 0 errors.
  1 row inserted, 8 values computed.
</pre>

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
# View transcript
podcasts.select(podcasts.title, podcasts.transcript_text).collect()
```

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
# View summary
podcasts.select(podcasts.title, podcasts.summary).collect()
```

## Explanation

**Pipeline architecture:**

<pre>
  Audio → Whisper transcription → Transcript text → LLM summarization → Summary
</pre>

Each step is a computed column that depends on the previous one. When
you insert a new audio file, all steps run automatically in sequence.

**Whisper model options:**

For production with varied audio quality, use `small.en` or larger.

## See also

* [Transcribe
  audio](https://docs.pixeltable.com/howto/cookbooks/audio/audio-transcribe.md) -
  Basic audio transcription
* [Summarize
  text](https://docs.pixeltable.com/howto/cookbooks/text/text-summarize.md) -
  Text summarization patterns


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.