WebToSpeech

For publishers · Add an audio player to an Astro blog

Put an audio player on every Astro post.

Add two lines to your Astro post layout and every Markdown or MDX article gets a cookie-free audio player—with zero React, Vue, or client hydration required.

Works with Astro Content Collections, Starlight docs, static builds, and SSR deployments. Requires the Publisher plan.

  1. Step 1

    Register your Astro site in WebtoSpeech

    Add your production domain in Settings → Sites to get your verification meta tag and ws_ site key.

  2. Step 2

    Add the verification tag to your base head

    Paste the verification meta tag into your BaseHead.astro (or layout <head>), deploy, and click Verify in WebtoSpeech. You can also verify via a DNS TXT record instead.

    src/components/BaseHead.astro

    <meta name="webtospeech-verification" content="your_verification_code">
  3. Step 3

    Add the player to your post layout

    Place the player element right above <slot /> in your BlogPost.astro layout, and include is:inline on the script tag so Astro outputs the external script verbatim without bundling it.

    src/layouts/BlogPost.astro

    <div data-webtospeech></div>
    <script is:inline src="https://webtospeech.app/embed.js" data-site="ws_your_site_key" async></script>
  4. Step 4

    Deploy and press play on a live post

    Once deployed to your verified domain, open any post and press play. Audio streams within seconds on the first play and is cached for every reader afterwards.

    If your Astro site outputs <link rel="canonical"> and <meta property="article:modified_time">, WebtoSpeech uses them automatically to keep edited posts in sync.

Control dark mode or opt out per post

Pass data-theme="light" or data-theme="dark" if your Astro theme uses a manual toggle instead of prefers-color-scheme, or wrap the snippet in a front-matter flag like {!frontmatter.hideAudio && ...}.

src/layouts/BlogPost.astro

{!frontmatter.hideAudio && (
  <div data-webtospeech data-theme="dark"></div>
)}

Good to know on Astro

Always include is:inline on the script tag

Astro tries to bundle <script> tags that have no attributes. Adding is:inline preserves data-site and async cleanly in the rendered HTML.

Canonical URLs keep trailing slashes tidy

Set site in astro.config.mjs and render <link rel="canonical"> in your head so /posts/hello and /posts/hello/ share one generated audio file.

Using Astro View Transitions (<ClientRouter />)?

If you use client-side View Transitions, keep the script tag inside your post layout or re-run mount logic on astro:page-load, or disable transitions on long-form blog posts.

Connect @astrojs/rss for an automatic podcast

Already generating /rss.xml with @astrojs/rss? Connect it in Settings → Sites → Feed and podcast to publish every new Astro post to Apple Podcasts and Spotify.

See everything else the player does

Questions

Does the WebtoSpeech player work on statically generated Astro sites?
Yes. The player is plain HTML plus an async external script, so static Astro builds hosted on Cloudflare Pages, Netlify, Vercel, or GitHub Pages work without a backend.
Why does the Astro snippet use is:inline?
Without is:inline, Astro’s compiler processes script tags during the Vite build. Adding is:inline leaves the external embed.js tag and its data-site attribute untouched.
Will preview deployments on pages.dev or vercel.app play audio?
Players only run on verified domains registered in Settings → Sites, so production traffic works cleanly while unauthorized domains cannot frame your player.

Publisher plan

$29 a month. Unlimited sites.

200 hours of audio a month, every Studio and standard voice, cookie-free embeds, RSS-to-podcast feeds, and play counts.