AISanity2 MIN READ
22.12.2025
.md

Automating Audio Narration with Sanity Blueprints and Google Text-to-Speech

Last updated: 25.12.2025

🎧

Automating Audio Narration with Sanity Blueprints and Google Text-to-Speech

Audio Narration

studio microphone

I recently built an automated audio narration pipeline for my blog using Sanity, Next.js, and Google Cloud Text-to-Speech. The goal was simple: whenever the actual content of a blog post changes, regenerate a high-quality MP3 narration automatically — without manual steps, wasted API calls, or accidental infinite loops.

The key to making this reliable was leaning into Sanity's native automation tools, especially Blueprints, delta detection, and GROQ projections.

The Core Idea

Instead of generating audio on every page request, the system reacts to content changes at the CMS level:

  1. A blog post is updated in Sanity
  2. A Blueprint triggers only on document updates
  3. Sanity's delta function is used to detect whether the body field actually changed
  4. If (and only if) the body changed, Sanity calls a secure webhook
  5. A Next.js API route generates narration using Google Text-to-Speech
  6. The resulting MP3 is uploaded back into Sanity as a file asset
  7. The post is patched with a reference to the audio file

This ensures narration is generated once per meaningful content change, not per request or per publish event.

Why Blueprints + Delta Matter

Sanity already knows exactly what changed in a document. By using delta I avoided fragile solutions like hashing Portable Text or doing deep JSON diffs. Combined with GROQ filters and projections, the Blueprint stays declarative, readable, and easy to maintain.

To prevent infinite loops (since uploading audio also updates the document), the function is only checking the delta in the body text and if the text audio file exist.

Why Store Audio in Sanity?

For a personal blog, storing the MP3 directly in Sanity works surprisingly well:

  • The audio is served via Sanity's CDN
  • Each post owns its narration
  • No extra storage service is required
  • Editorial state and content stay in one place

The Result

The end result is a fully automated, content-driven audio system:

  • No manual triggers
  • No unnecessary TTS calls
  • No client-side secrets
  • Clean separation of concerns

This setup scales well, respects cost limits, and fits naturally into Sanity's content model — exactly what I was aiming for.

Continue Reading
A pegboard of hand tools above a workbench, one tool lifted out of its painted outline.
AIClaude3 MIN

When the Claude window runs out: my take on T3 Code

T3 Code addresses the frustration of hitting Claude’s five-hour usage limit during focused work. Rather than replacing coding agents, it provides a single desktop interface for tools such as Claude Code, Codex, Cursor, Grok Build, OpenCode, and Antigravity, with users signing in through their own accounts. Each thread remains tied to its original provider, so an unfinished Claude conversation cannot be transferred directly to Codex. However, the surrounding workspace, project, and workflow stay in one app. When a limit is reached, T3 Code identifies the restriction and reset time, allowing the user to start a new thread with another provider and quickly restate the task. The app is free and does not resell or mark up tokens, aligning its incentives with users who want to avoid unnecessary calls. Its MIT license, self-hosting support, public codebase, and more than 21,000 GitHub stars are especially important because it handles provider credentials and repository access. Although founder Theo frequently promotes the product, its transparency makes those claims easier to verify. The Linux desktop app remains young and occasional releases cause problems, but steady improvements and its ability to coordinate separate agents make it a practical solution for maintaining momentum.

Read post
A carefully built sandcastle standing intact in a wooden sandbox in early morning light.
ClaudeAISecurityTypeScript3 MIN

Trying out autonomous agents

Sandcastle is Matt Pocock’s workflow for running Claude Code unattended inside a Docker container. It assigns the agent a GitHub issue in a git worktree, then merges the resulting commits back into the user’s branch. Its init command quickly scaffolds the infrastructure, but useful results still depend on supplying clear, focused tickets. Wayfinder fills that planning gap by breaking an idea that is too large for one session into a map issue and smaller decision tickets. Each ticket addresses a single unresolved question rather than a build segment, producing the self-contained, labeled issues Sandcastle needs. Without this map, vague issues led to equally vague pull requests. Before queueing work, the author uses a grilling skill to challenge assumptions and force difficult decisions. Resolving uncertainty early prevents the agent from making costly guesses during unattended runs. For secrets, the author replaces a plaintext .env file with Varlock and a committed .env.schema. Values are resolved through Doppler and exposed only through process.env during execution, although each secret must still be explicitly forwarded into the container configuration. The author would use the setup again but stresses that ticket quality remains decisive. Every diff is still reviewed, tasks stay tightly scoped, and fully unattended overnight operation remains a future goal.

Read post