Web DevelopmentText-to-Speech

Adding Text to Speech to Vue

Learn how browser speech works, why AI TTS matters, and how to integrate TTS2Go into your Vue app for high-quality, cost-controlled audio.

Anthony Morris·

Giving your Vue application a voice opens up new possibilities for accessibility, engagement, and user experience. Whether you are building a content site, an e-learning platform, or a dashboard that reads out alerts, text-to-speech (TTS) lets users consume your content hands-free.

This guide explains how browser speech works, the trade-offs of different approaches, and how to wire up TTS2Go in your Vue project.

How Browser Speech Synthesis Works

Every modern browser includes the Web Speech API. With a few lines of JavaScript using window.speechSynthesis.speak() and a SpeechSynthesisUtterance, you can read text aloud without any external service or API key.

Key characteristics:

  • Runs entirely on the client – no backend or API calls required.
  • Completely free – no usage-based billing.
  • Instant to integrate – minimal JavaScript.

The main drawback is quality. Browser voices often sound mechanical, vary significantly across operating systems and browsers, and offer limited voice selection. The same text can sound completely different on Chrome versus Safari or Windows versus macOS.

The Rise of AI-Generated Speech

AI-powered text-to-speech models produce audio that is nearly indistinguishable from a human speaker, with natural rhythm, emphasis, and tone. These services typically offer:

  • Dozens of languages
  • Hundreds of unique voices
  • More control over style, pacing, and emotion

The trade-off is that generating this audio costs money and requires an API call. That introduces a key question: how do you control when audio gets generated and who pays for it?

Pre-Generating Audio

One approach is to generate all your audio in advance and serve it as static files from a CDN.

Pros:

  • Playback is instant.
  • Audio quality is consistent for every listener.

Cons:

  • You pay to generate audio for every piece of content, whether anyone listens or not.
  • You must know all your content up front.
  • Any content update means re-running your generation pipeline.
  • Storage costs grow linearly with your catalog.

This can work for small, stable content libraries, but it becomes expensive and inflexible at scale.

Lazy Generation on Demand

A more efficient strategy is to generate audio only when a user requests it.

How TTS2Go Solves This

TTS2Go balances quality, cost, and simplicity with a hybrid model.

  1. Safe frontend key

You add the SDK to your site with a frontend API key. The key uses request domain blocking and rate limiting so it can safely live in your client-side code. It is an identification and rate limiting mechanism, not a secret.

  1. First visitor: browser TTS + background generation

When the first person clicks a TTS button on a piece of content:

  • They hear browser speech synthesis immediately.
  • At the same time, a generation request is sent to TTS2Go in the background.
  1. Approval and budget control

In your TTS2Go dashboard you can:

  • Manually approve or reject generation requests, or
  • Configure the AI approval system to auto-approve requests that meet your criteria.

This gives you full control over your generation budget.

  1. Subsequent visitors: instant AI audio

Once a request is approved and generated, every subsequent user who clicks TTS on that same content gets high-quality AI audio in your chosen voice, served instantly from TTS2Go's CDN.

The result:

  • Your first visitor gets a functional experience with browser TTS.
  • Your costs are controlled through approval and rate limiting.
  • Everyone after that gets premium AI audio without extra latency.

Step 1: Install the SDK

Add the TTS2Go Vue package to your project:

[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

The package is lightweight and works with Vue 3 and the Composition API out of the box.

Step 2: Register the Plugin

Install the TTS2GoPlugin when you create your Vue app. This provides the TTS2Go client to every component through Vue's dependency injection.

[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

Step 3: Add Text to Speech in a Component

Use the useTTS composable in any component to get reactive playback controls. You can also use the pre-built TTSButton component for a ready-made UI.

[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

Behavior:

  • The first click triggers browser TTS and sends a generation request to TTS2Go in the background.
  • Once the request is approved and generated in your dashboard, all future users who click TTS on that same content get high-quality AI audio instead of browser speech.

What Is Next?

From here, you can explore more advanced TTS2Go features for Vue:

  • Voice selection – choose from multiple voices and languages.
  • SSML support – fine-tune pronunciation, emphasis, pauses, and pacing.
  • Highlight API – sync on-screen text with spoken words for better accessibility and comprehension.

For full Vue documentation and advanced examples, visit:

  • tts2go.com/docs/vue