speech-driven emphasis


npm ↗
GitHub ↗
TypeScriptZero dependenciesReact + Vanilla JS

When a browser reads text aloud with speech synthesis, nothing on the page shows which word is being spoken. speechType listens to the Web Speech API’s boundary events and marks each word as it is spoken: by default with weight, optical size and spacing on a plain span around each word, or, with the opt-in highlight mode available in 1.2.0, by painting a range without adding word wrappers. The text stays real text either way: links keep their names, and the accessibility tree keeps the paragraph you wrote.

Live demo — step with the Word slider or press Speak if supported

Mark the spoken word with

Each word sits in its own plain span: nothing is hidden and no label is added. The spoken word gets heavier, uses a higher opsz axis value and more tracking, and carries aria-current, the one attribute speechType writes. CSS font size stays the same. These styles make the active word wider in this specimen, moving following words and sometimes rewrapping a line.

Word—
Active weight700
Inactive opacity0.75

Dimming lowers the contrast of the words not being spoken.

Rate0.9×
Transition80ms

Every word spoken carries its own weight, a breath of meaning that arrives, lingers, and fades. To read aloud is to make language visible in time, each syllable a footprint left in the air. The voice knows where it is. The page does not.

Press Speak to hear the paragraph read aloud by your browser’s speech synthesis, with each word marked as it is spoken, or use the Word slider to step through by hand. “read aloud” is a real link: it stays a link, with its name, in both modes. Meant for read-along reading aids, language learning and teleprompters. It is not a screen reader and doesn’t replace one.

What splitting text costs — measured on this page

speechType’s span mode wraps each word so it can be styled separately. The DOM-based movement techniques compared here use independently styled pieces too. Until version 1.1.0, speechType also hid its spans from screen readers, a mistake several of our tools made. Below, compare one sentence as written, split by a published library running in your browser, and wrapped in place. Each version reports its measured width and the structure it offers assistive technology.

The words used here. A screen reader presents interface and document information through speech and/or braille; its users may also have usable vision. It uses information exposed through the browser’s accessibility tree, rather than simply reading pixels. In that list each thing has a role (paragraph, link, heading) and may have a name (for a link, its words). A tab stop is a place the Tab key lands. aria-hidden removes something from that list; aria-label gives something a name by hand. An inline-block is a piece of text made into its own small box, which is what lets an animation move it. Kerning adjusts spacing between particular glyph pairs, bringing them closer or farther apart. A ligature replaces a character sequence with a glyph, which need not be a joined shape. Cursive joining supplies contextual connected forms. These shaping operations depend on context and formatting boundaries.

57 of 90 characters
Split by
Split into
Element
Wrapped-in-place pieces
font-kerning on all three
Unsplit
Split by GSAP SplitText 3.15.0
Wrapped in place, inline

The dashed rule marks where the unsplit line ends. Set in Source Serif 4; emoji, Devanagari and Arabic come from your system’s fonts. The effect is a fade; pieces that are boxes also rise, because a transform (moving, turning or scaling a piece) does nothing to an inline span. The one exception is words wrapped inline, which are speechType’s own spans: their button plays its real emphasis, a heavier, wider word. Where the link’s underline breaks up, that is the split as well: an underline isn’t drawn across inline-block pieces.

Unsplit

The sentence as written. Its button runs speechType’s highlight mode (available as an opt-in mode in 1.2.0): it paints each word with the CSS Custom Highlight API and adds nothing to the page. This demo uses colour and background; the API permits restricted painting properties, subject to browser support, not font weight, font size or transforms.

Measuring…

Split by GSAP SplitText 3.15.0

Default aria: "auto": copies the text into aria-label on the element and puts aria-hidden on every piece.

SplitText.create(el, { type: "chars,words" })

Measuring…

Wrapped in place, inline

A plain span around each character, nothing else: no ARIA attributes. (speechType itself wraps words; this is the same idea per character.)

Measuring…

What screen readers did with the aria-label pattern (not our test)

We ran no screen reader. Adrian Roselli did: he tested GSAP’s own SplitText demo, a <div> with an aria-label and aria-hidden pieces, in eight screen reader and browser pairings and reported which ones exposed the text (GSAP issue 642, 5 February 2026). Two did. His table covers that one demo on a <div>; a heading may be named, so a split <h2> is a different case. It is the only published test of this pattern we found, and we looked in the libraries’ own issue trackers, not everywhere.

  • NVDA / Firefox: yes
  • JAWS / Chrome: no
  • Narrator / Edge: no
  • VoiceOver macOS / Safari: no
  • Orca / Firefox: no
  • TalkBack / Chrome: yes
  • TalkBack / Firefox: no
  • VoiceOver iPadOS / Safari: no

How to read this. Roles, names, tab stops and text objects are computed in your browser from the live markup, following the accessible-name rules (AccName 1.2). They describe what the page offers assistive technology, not what any screen reader says. The original sweep checked 1,603 states / 4,809 column readings and found 198 NBSP name mismatches (90 plain, 90 kept, 18 split). After preserving NBSP, a rebuilt-site check covered 91 states / 273 column readings and still found six host-name spacing mismatches, all in anime.js heading cases. These computed names remain approximations, not verified browser-tree equivalents; inspect Chrome’s tree independently. See the dated status and method. One known difference: Chrome stops building a name from content after 100 objects, so a heading split into inline-block characters (the first preset is long enough) gets a shorter name in Chrome than the full one shown here. Widths are measured from the rendered lines, so they change with your browser, zoom and fonts.

More pieces is not the same as broken. Ordinary inline wrapping keeps the words and link names in our browser checks, but adds text objects. Making each character an independent box can change the names too. Whether a screen reader runs the pieces together is something this page can’t tell: a 2018 report from a VoiceOver user found iOS stopping at each inline element inside a link. The unsplit row, anime.js’s hidden copy and “boxes beside the real text” keep a copy of the sentence in its original pieces.

Limits. One font and one line. What splitting into letters costs depends on the text and the chosen library. The kerning-pair and joined-script presets can change substantially; use the live width readings for your selected state. Splitting by words usually costs less width, although GSAP’s link can still lose its name. A plain inline span keeps shaping across its boundary while the formatting allows it: changing weight or size can require separate shaping. Motion+ splitText is not included in this live comparison.

How it works

The audio-text gap

When the browser speaks text via SpeechSynthesisUtterance, words are heard but not seen. There is no CSS property that tracks synthesis progress — the visual and the auditory are decoupled by design. speechType closes that gap.

Boundary events drive emphasis

The Web Speech API fires boundary events as each word begins. speechType maps the reported character index to the word and applies typographic emphasis (wider tracking, heavier weight, larger optical size) while dimming the other words. Not every voice sends word boundaries; with one that doesn't, the text is spoken and nothing is marked.

Imperative for performance

During active speech, startSpeechType handles each boundary event directly — updating span styles without touching React state or triggering re-renders. The boundary event fires, the span style changes, and the frame is painted. No scheduling, no batching delay.

React or vanilla JS

SpeechTypeText and useSpeechType manage span preparation and React-driven emphasis. startSpeechType is the vanilla JS entry point — it wraps, speaks, and syncs, returning a stop function.

Usage

TypeScript + React · Vanilla JS

Drop-in component

import { SpeechTypeText, startSpeechType } from '@overpunch/speechtype'
import { useRef, useState } from 'react'

// Drive activeWordIndex via startSpeechType or your own state
const [activeWordIndex, setActiveWordIndex] = useState(-1)
const ref = useRef<HTMLParagraphElement>(null)

// startSpeechType updates the spans imperatively during speech:
<SpeechTypeText ref={ref} activeWordIndex={activeWordIndex}>
  The voice knows where it is. The page does not.
</SpeechTypeText>

Start speech synthesis and sync emphasis

import { startSpeechType } from '@overpunch/speechtype'

const el = document.querySelector('p')
const stop = startSpeechType(el, { rate: 0.9, activeWeight: 700 })

// Later — cancel speech and restore styles:
// stop()

Hook — manual control with your own active index

import { useSpeechType } from '@overpunch/speechtype'
import { useRef } from 'react'

// Inside a React component:
const ref = useRef(null)
useSpeechType(ref, activeWordIndex, { inactiveOpacity: 0.4 })
return <p ref={ref}>Every word spoken carries its own weight.</p>

Options

OptionDefaultDescription
activeTracking0.06Letter-spacing on the active word in em.
activeWeight+300wght axis value on the active word. Unset: the word's own weight plus 300 (400 becomes 700).
activeOpsz×1.5opsz axis value on the active word. Unset: 1.5 times the word's own optical size.
inactiveOpacity0.6Opacity of words not currently spoken. The published 1.2.0 default is 0.6. Dimming lowers contrast while a word is active and can still fail WCAG AA on your palette; check the actual composited colours. Set to 1 for no dimming.
transitionMs80CSS transition duration in ms for style changes.
mode'spans'Available in 1.2.0. 'spans' remains the default; opt into 'highlight' to paint the spoken word without wrappers using ::highlight(speechtype). The API supports restricted painting properties, including colour, background, text decoration and text shadow where supported, not font weight, font size or transforms. Falls back to spans where the API is missing.
rate0.9Speech rate (0.1–10). Accepted by all paths; speech options (rate, pitch, volume) are silently ignored by SpeechTypeText and useSpeechType.
pitch1Speech pitch (0–2). Silently ignored by SpeechTypeText and useSpeechType.
volume1Speech volume (0–1). Silently ignored by SpeechTypeText and useSpeechType.
onUnsupported—Called when the browser does not support SpeechSynthesis.
onError—Called with the SpeechSynthesisErrorEvent if synthesis errors.
as'p'HTML element to render. (SpeechTypeText only)

Limits

no-code

Use it in Webflow

The same effect, no build step — drop it straight into your design tool.

Webflow

One script tag, then mark any element with data-speechtype. Configure it with data-* attributes.

<!-- Site Settings → Custom Code → Footer, or an Embed element -->
<script src="https://cdn.jsdelivr.net/npm/@overpunch/speechtype/dist/speechtype.webflow.min.js"></script>

<!-- Then add data-speechtype to any text element -->
<h1 data-speechtype>Your headline</h1>