Skip to content
UsecaseBoard
← All use cases
dev.toAudio

Generate a podcast file through an asynchronous Worker API

At a glance

A blogger built podcast-it to turn article text into narration and downloadable audio using OpenAI and Cloudflare. This workflow is listed under Audio, Content Tools, APIs.

SourceBuilding a tool for these workflows? See weekly rates.

What they did

1) Have Node.js and Cloudflare/OpenAI access. Download h93xV2/podcast-it and run `npm install`. Set OPENAI_API_KEY in local `.dev.vars`; run `npx wrangler login`. Create resources with `npx wrangler r2 bucket create podcasts`, `npx wrangler d1 create podcasts` and `npx wrangler queues create episodes`. Put the returned database ID in `wrangler.jsonc`, retaining its bucket, database and queue bindings. 2) Run `npm run dev`, which applies local migrations, and open http://localhost:8787 for the API interface. 3) POST JSON to `/api/episodes` with unique `slug`, article text as `content`, `episodeTitle`, `showTitle`, and `hosts` containing a name and voice such as alloy. The queue consumer generates a narration script and speech, storing audio in R2 and metadata in D1. 4) Poll `/api/episodes/<slug>` until status is complete and `audioFile` is populated. Download `/api/audio/<audioFile>` and listen.

How it went

The tutorial demonstrates a 202 creation response, pending-to-complete status and audio retrieval. Duplicate slugs return 409.

Worth knowing

The linked repository adds a queue and title fields to the article's example. Its package script is npm run dev; the README's npm start is stale.

Save ideas in this browser. Upvotes count across the board.

Prompt excerpt

No prompt excerpt was provided by the source.

Sponsored

CodeBuddy

Tencent Cloud AI coding assistant for IDE and CLI.

Try CodeBuddy ↗
Explore all →