Audio Sandbox

Plays on all browsers:
<audio autoplay="autoplay">
<source src="./swf_audio.mp3"></audio>
OpenAI provides audio generation through ChatGPT and through the API.

In ChatGPT:

If your version of ChatGPT includes audio tools, you can ask for things like:
  • "Generate a voiceover for this script."
  • "Read this paragraph in a professional narrator voice."
  • "Create a podcast-style introduction."
You can also use Voice Mode to interact by speaking and listening, although that's primarily for conversation rather than producing downloadable audio files.

Using the OpenAI API

OpenAI's text-to-speech models can generate spoken audio from text.

The main documentation is here:

Text to speech

Typical workflow:
  1. Send text to the API.
  2. Choose a voice.
  3. Receive an MP3 or other audio file.
Example in JavaScript:
import fs from "fs";
import OpenAI from "openai";

const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
});

const mp3 = await openai.audio.speech.create({
  model: "gpt-4o-mini-tts",
  voice: "alloy",
  input: "Welcome to our product demonstration.",
});

const buffer = Buffer.from(await mp3.arrayBuffer());
fs.writeFileSync("speech.mp3", buffer);
Creating audio for a Sora video

Sora currently focuses on video generation. If you generate a video and want narration or music:
  1. Generate the video with Sora.
  2. Generate narration separately using OpenAI text-to-speech.
  3. Combine the video and audio in a video editor such as DaVinci Resolve, Adobe Premiere Pro, or CapCut.