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 closed notebook with a wrench, a magnifying glass and a ruler tucked under its elastic band.
AI3 MIN

My blog has tools now: WebMCP for browser agents

The blog builds on its Markdown-first approach by adding WebMCP, a draft W3C technology that lets web pages expose structured tools to browser-based agents. Rather than forcing an agent to inspect pages, infer URLs, and construct requests, WebMCP provides a concise list of callable tools registered through `document.modelContext.registerTool()`. Chrome supports it experimentally through an origin trial beginning with version 149. Every page on the blog offers three read-only tools: `list_posts`, which returns recent posts with optional category and limit filters; `get_post`, which retrieves a post’s full Markdown by slug; and `list_categories`, which lists categories and post counts. These tools simply fetch existing public Markdown endpoints, so the same information remains accessible without WebMCP. Users can inspect and invoke the tools in Chrome DevTools under Application > WebMCP or query them from the console. Agents can also access them through Chrome DevTools MCP, while an inspector extension supports prompting with Gemini. However, current access depends on flags, experimental options, or an origin trial, and tools are visible only while a page is open. Keeping them as thin wrappers ensures the blog remains functional if WebMCP changes or disappears.

Read post
A school report card with a pie chart, 68 shaded in teal and the rest filled in with red pen to make 100.
AISEOClaude4 MIN

From 68 to 100: making my blog readable for AI agents

Is Agentic is a free tool that evaluates how accessible a website is to AI agents. It scans a URL, assigns a score out of 100, provides supporting evidence, and recommends fixes across essential, recommended, and bonus checks. The author’s blog initially scored 68. Using the report and Claude Code, the author added Markdown versions of posts, listings, the homepage, and error pages so agents could access content and recover from broken links more easily. Other improvements included structured data identifying the site and author, a clearer title, properly ordered headings, and an updated llms.txt file explaining when the personal blog is an appropriate source. Reviewing the site from an agent’s perspective also revealed a hidden linking bug: Markdown posts pointed to nonexistent /post/ URLs instead of /posts/. After fixes, the site scored 100, although that total included bonus points and concealed two recommended-check gaps. Contact and Privacy pages were added, while one search-ranking check remains unresolved because its results differ from Google’s. Website owners can test their own sites at is-agentic.com, prioritize failed essential checks, implement fixes, and rescan. Reports retain the same shareable URL while displaying the latest results.

Read post