Skip to main content
Open in Kaggle  Open in Colab  Download Notebook
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.
Generate natural-sounding audio from text using OpenAI’s text-to-speech models.

Problem

You need to convert text content into spoken audio—for accessibility, content repurposing, or voice applications.

Solution

What’s in this recipe:
  • Generate speech with OpenAI TTS
  • Choose from multiple voice options
  • Store text and audio together
You add a computed column that converts text to audio. The audio is cached and only regenerated when the source text changes.

Setup

Connected to Pixeltable database at: postgresql+psycopg://postgres:@/pixeltable?host=/Users/pjlb/.pixeltable/pgdata
Created directory ‘tts_demo’.
<pixeltable.catalog.dir.Dir at 0x17f0d5bd0>

Create text-to-speech pipeline

Created table ‘articles’.
Added 0 column values with 0 errors.
No rows affected.

Generate audio

Inserting rows into `articles`: 2 rows [00:00, 423.90 rows/s]
Inserted 2 rows with 0 errors.
2 rows inserted, 6 values computed.

Explanation

OpenAI TTS models:
Voice options:
Tips:
  • Use tts-1 for drafts and real-time applications
  • Use tts-1-hd for final production audio
  • Audio is cached—no regeneration on queries

See also

Last modified on June 24, 2026