AI

Build a Crash-Resistant AI Podcast Production Pipeline on Telnyx Edge

Podcast post-production is a pipeline, not a single model call. A transcript must exist before chapters can be marked. Chapters must exist before useful show notes and a trailer script can be written. Speech synthesis cannot begin until that script is ready.

That sequence creates a practical reliability problem: what happens when a long-running job fails after transcription but before the trailer is finished? Starting over wastes time and repeats expensive work. Holding every intermediate result only in memory risks losing the entire run.

show-wrap-desk is an open-source TypeScript example that models podcast post-production as a durable workflow on Telnyx Edge Compute. One Stateful Actor per show owns the episode ledger, scheduled work, chapters, and generated assets.

A producer submits a recording once. The desk processes it in stages:

transcribing -> chapterizing -> notes -> wrapped

The finished package includes a speaker-labeled transcript, timestamped chapters, AI-written show notes, and an MP3 trailer generated through the Telnyx Text-to-Speech WebSocket.

The API surface

The worker exposes four routes:

  • POST /wrap registers a new episode or resumes an unfinished episode with the same audio URL.
  • GET /wrapstatus/{episodeId}?show={show} returns its status, chapters, notes preview, trailer size, and the show's episode ledger.
  • GET /health/liveness provides a liveness check.
  • GET /health/readiness provides a readiness check.

Starting a wrap returns immediately with 202 Accepted:

curl -X POST https://<your-worker>/wrap \
  -H "Content-Type: application/json" \
  -d '{
    "show": "engineering-notes",
    "audioUrl": "https://example.com/episode.mp3"
  }'
{
  "episodeId": "a1b2c3d4-...",
  "status": "transcribing",
  "resumed": false
}

The processing work continues inside the show's actor rather than keeping the original HTTP request open.

One durable desk per show

The outer worker derives an actor name from the show:

export function deskName(show: string): string {
  return `show:${show}`;
}

const desk = env.DESKS.idFromName(deskName(show));
const result = await desk.onWrap(show, audioUrl);

The same show name always resolves to the same WrapDesk actor. That actor owns all episodes for the show while another show receives a separate actor and separate state.

The actor uses its embedded SQL storage for three ledgers:

CREATE TABLE episodes (
  ep_id TEXT PRIMARY KEY,
  audio_url TEXT NOT NULL,
  status TEXT NOT NULL,
  error TEXT,
  created_at TEXT NOT NULL,
  wrapped_at TEXT
);

CREATE TABLE chapters (
  ep_id TEXT NOT NULL,
  idx INTEGER NOT NULL,
  title TEXT NOT NULL,
  start REAL NOT NULL,
  end REAL NOT NULL,
  PRIMARY KEY (ep_id, idx)
);

CREATE TABLE assets (
  ep_id TEXT NOT NULL,
  kind TEXT NOT NULL,
  content TEXT NOT NULL,
  created_at TEXT NOT NULL,
  PRIMARY KEY (ep_id, kind)
);

No external workflow database is required for the sample. Episode progress, chapter metadata, transcripts, notes, and trailer audio all live with the actor.

Stable task IDs make resuming predictable

When an episode is registered, the actor schedules wrapTick under a stable task ID:

await this.schedule(
  0,
  "wrapTick",
  { episodeId },
  { id: `wrap:${episodeId}` }
);

Scheduling another task with the same ID replaces the pending task instead of creating a duplicate. Each successful stage updates the episode status and re-arms the same task for the next stage.

If the same show and audio URL are posted again while the episode is unfinished, onWrap finds that ledger entry, re-arms wrap:<episodeId>, and returns resumed: true.

Agent SDK scheduled tasks are delivered at least once and retry thrown errors with backoff. The stage handlers therefore check their persisted outputs before repeating work:

  • Transcription is skipped when a transcript asset already exists.
  • Chapter generation is skipped when chapter rows already exist.
  • Show notes are skipped when the notes asset already exists.
  • Trailer synthesis is skipped when the trailer asset already exists.

This does not make an external API call magically atomic. A crash between receiving a response and persisting it can repeat the current stage. But once a stage's output is committed, later attempts move forward without recreating that asset.

Stage 1: diarized transcription

The actor downloads the public audio URL and uploads the recording to the Telnyx Speech-to-Text API as multipart form data:

const form = new FormData();
form.append("file", blob, "episode.mp3");
form.append("model", "deepgram/nova-3");
form.append("response_format", "verbose_json");
form.append(
  "model_config",
  JSON.stringify({
    diarize: true,
    smart_format: true,
    punctuate: true,
  })
);

Deepgram Nova-3 returns word-level timing and speaker information through Telnyx. The actor normalizes that response into words containing word, start, end, confidence, and speaker, then stores the array as the episode's transcript asset.

After the transcript is persisted, the episode advances to chapterizing.

Stage 2: chapter boundaries and titles

The sample first groups consecutive words from the same speaker into turns. It then starts a new chapter when the gap between turns exceeds 60 seconds:

const turns = buildTurns(words);
const chapters = splitIntoChapters(turns, CHAPTER_GAP_S);

This boundary detection is local code. It does not spend a model call deciding where each chapter starts.

One Telnyx AI Inference request receives short summaries of all chapter spans and returns a JSON array of titles. If the response cannot be parsed, the code falls back to Chapter 1, Chapter 2, and so on.

The default model is zai-org/GLM-5.3-Flash, called through the preconfigured TELNYX Edge binding:

const completion =
  await this.env.TELNYX.ai.openai.chat.createCompletion({
    model,
    messages: [
      { role: "system", content: systemPrompt },
      { role: "user", content: prompt },
    ],
    max_tokens: 1200,
    temperature: 0.4,
  });

The inference call does not require a separate model-provider credential in the application.

Stage 3: show notes and trailer

The next stage asks the model for Markdown show notes containing:

  • a one-paragraph summary
  • key takeaways
  • one pull quote

The sample sends a bounded transcript excerpt plus the chapter titles and timestamps. After the notes asset is stored, the desk re-arms its task before beginning trailer generation in a later invocation. Splitting those operations helps keep each task within the runtime's method-duration budget.

For the trailer, the model selects a chapter from the available chapter titles and returns a teaser of no more than 400 characters. The desk then opens the Telnyx Text-to-Speech WebSocket using the configured HOST_VOICE.

The WebSocket exchange is explicit:

socket.send(JSON.stringify({ text: " " }));
socket.send(JSON.stringify({ text: script }));
socket.send(JSON.stringify({ text: "" }));

The initial space initializes the stream, the second frame carries the trailer script, and the empty string flushes the input. The actor collects base64-encoded audio frames until it receives isFinal: true.

The default configured voice is azure.en-US-AvaMultilingualNeural. You can replace HOST_VOICE with another supported voice. Using a custom or cloned host voice requires configuring an appropriate voice; the sample does not create a voice clone from the episode recording.

When the trailer is stored, the episode status becomes wrapped.

Inspecting the result

Poll the status route with the episode and show identifiers:

curl "https://<your-worker>/wrapstatus/<episodeId>?show=engineering-notes"

A completed response includes chapter titles and timestamps, a notes preview, the decoded trailer size, and the show's episode ledger:

{
  "status": "wrapped",
  "chapters": [
    {
      "title": "Designing Durable AI Workflows",
      "start": 0,
      "end": 184.2
    }
  ],
  "notesPreview": "# Show Notes\\n\\nIn this episode...",
  "trailerBytes": 156960,
  "episodes": [
    {
      "ep_id": "a1b2c3d4-...",
      "audio_url": "https://example.com/episode.mp3",
      "status": "wrapped",
      "created_at": "2026-10-15T20:00:00.000Z",
      "wrapped_at": "2026-10-15T20:03:12.000Z"
    }
  ]
}

Run it

Clone the examples repository and configure the project:

git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/show-wrap-desk
npm install
cp .env.example .env

Add your Telnyx API key to .env, then generate bindings and deploy:

npm run types
npm run deploy

Set the printed worker URL as DEPLOY_URL in .env, then run the included bootstrap client:

npm run bootstrap

The default demo uses a public-domain LibriVox recording, so the workflow can be exercised without uploading a private episode.

Before adapting it for production

The sample focuses on orchestration, not a complete podcast platform. A production version should add:

  • Authentication and authorization for /wrap and /wrapstatus.
  • Limits on remote audio size, duration, format, and allowed source hosts.
  • Validation and sanitization before fetching user-supplied URLs.
  • Retention, encryption, and deletion policies for transcripts and generated media.
  • Durable object storage for large audio assets rather than keeping base64 audio in actor SQL.
  • Evaluation and human review for chapter titles, show notes, and promotional claims.
  • Usage, latency, retry, and failure telemetry for every external operation.
  • A strategy for long transcripts that exceeds a single inference context window.

The reusable pattern

Show Wrap Desk is a podcast example, but the orchestration pattern is broader:

  1. Give each customer or workload a deterministic actor.
  2. Store stage outputs before advancing.
  3. Represent progress as explicit statuses.
  4. Schedule work under stable IDs.
  5. Make every stage safe to attempt again.
  6. Expose a status API backed by the durable ledger.

That same structure can support transcription batches, media processing, document enrichment, report generation, or any multi-stage AI workflow that should recover without restarting completed work.

Ready to build with low-latency voice AI?

Join developers building the future of real-time conversations