Skip to content
Sign upPro
VoiceVoice typeMenu

Voice type

A live transcript whose letter weight follows how loudly each word was said, so a spoken sentence keeps its emphasis on the page.

A caller moves a delivery to Thursday. Loud words print heavy, quiet ones light, and nothing reflows.

The word being said swells and thins with the speaker's level on the font's weight axis. When it ends it keeps the mean of its loudest half, so stressed words stay heavy and the small words between them stay light. Emphasis is weight only: no color, no size, no blur. Every word reserves its width before it moves, so nothing on the page ever reflows.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/voice-type.json

Usage

tsx
import { VoiceType } from "@/components/ui/chatcn/voice-type"

<VoiceType words={finalWords} current={partialWord} level={input.getLevel} />

It works with any voice stack. Pass the finished words from your recognizer, the word it is hearing now as current, and the microphone level as a number or a getter. Words without loudness keep what was heard while they were live; pass loudness yourself when your pipeline measures it per word. confidence below 0.6 marks a word as uncertain.

Examples

States

Quiet, loud, mixed, doubted words, a 240 px column and the fallback steps for a font without a weight axis.

How it stays still

  • Each word is an inline grid with two stacked cells: an invisible copy of the word sets the width and the visible text sits on top. While a word is live its copy is at the heaviest weight, so it can swell freely.
  • Once a word is printed its weight never changes again, so the copy drops to that weight and printed words keep their natural spacing. The only word that moves into the freed space is the next one, and it is just arriving. If the narrower word would fit on the line above, it keeps the heavy copy: nothing ever changes line.
  • Lines wrap greedily, set inline so a global text-wrap: pretty cannot rewrap earlier lines as words arrive.
  • The width copy is CSS generated content: it is never read aloud, selected, copied or found.

Fonts

Weight changes are smooth on a variable font with a weight axis, such as Geist (100 to 900). On mount the component looks for a variable face of its font in document.fonts and keeps the range inside that face's axis. A font without an axis, or a system font the page cannot see, falls back to the steps 400, 500, 600 and 700, still width reserved; the live word then waits at 400 and takes its step when it ends. Set axis to skip the check.

Props

PropTypeNotes
wordsVoiceTypeWord[]Finished words: text, optional loudness and confidence, 0 to 1
currentstringThe word being said now. Its weight follows level
levelnumber | () => number0 to 1. Getters are read at 30 fps without re-rendering
range[number, number]Weight for silence and for the loudest word. Default [300, 800]
donebooleanThe turn has ended: a word still live prints, and uncertain marks clear
simulatebooleanA built-in speech rhythm drives the live word when no level is passed
axis"auto" | "variable" | "steps"Default auto: the font's axis, steps without one
reducedMotionbooleanForce it on or off. Defaults to the user's setting

Helpers: voiceTypeWeight(loudness, range) is the weight a loudness prints at, voiceTypeFreeze(samples) the loudness a word keeps, and voiceTypeStep(loudness) the fallback step.

Accessibility

  • The paragraph's text is the plain words. There is no live region: announce finished turns from your transcript, never word by word.
  • Light weights keep the full text color. With prefers-contrast: more no word goes below 400 and uncertain words lose their dimming.
  • Uncertain words are dimmed to 70% with a dotted rule under them, never blurred. In forced colors the rule is a dotted underline.

Motion

  • The live word eases toward the level with a fast attack and a slower release, and never thins below the weight it has already earned, so a stressed word holds through its quiet tail and prints without a rebound.
  • New words appear in place at the level they are said at: no fade, no blur, no typing effect.
  • The loop runs only while a word is live, at 30 fps, and pauses off screen and in hidden tabs.
  • Reduced motion: the live word waits at 400 and takes its weight when it ends.