Skip to content
Sign in
ConversationVoice messageMenu

Voice messagePro

A voice note bubble whose waveform is the seek bar, with speed, an unplayed dot and a transcript that opens underneath.

ProVoice notes on both sides of a bakery chat. The waveform is the seek bar, and the transcript opens underneath.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/voice-message

Usage

tsx
import { VoiceMessage } from "@/components/ui/chatcn/pro/voice-message"

<VoiceMessage src={url} duration={14} peaks={peaks} transcript={transcript} unplayed />

The waveform is resampled to its width and drawn twice: faint underneath, ink on top clipped to the playhead, so the played part splits exactly where it is, through a bar if need be. Drag or use the arrow keys to seek; while you scrub the time follows your finger before the audio catches up. The time shows the length until you play, then the position. Speed cycles 1, 1.5 and 2×. Without src the component plays a clock for duration, which is what previews and tests use; pass audio from useMessageAudio to share one clock with a mini player. variant="flat" drops the fill for the other side of a chat.

Examples

States

ProNot played yet, paused part way with the transcript open, transcribing, no transcript, a long note, could not load, and disabled.

Props

PropTypeNotes
srcstringAudio file. Optional
durationnumberSeconds
peaksnumber[]Loudness samples, any length and scale
transcript, transcriptStatusstring, "idle" | "transcribing" | "done" | "error"
transcriptOpen, defaultTranscriptOpen, onTranscriptOpenChangeboolean
unplayed, onPlayedboolean, () => voidThe accent dot until played
audioMessageAudioA shared clock
variant"bubble" | "flat"Default bubble
disabledboolean
labelsPartial<VoiceMessageLabels>Every string, for translation

Keyboard

KeyAction
Space or Enter on playPlay or pause
Left and Right on the waveformBack or forward 5 s
Page Up and Page Down15 s
Home and EndStart and end

Accessibility

  • The waveform is a slider with the position read as 9 seconds of 22 seconds.
  • Play and speed buttons are named; the unplayed dot has a text alternative.
  • A file that fails to load says so in an alert; play is disabled.

Motion

Play and pause swap in 150 ms with a 2 px blur. The played part follows the playhead every frame while playing and eases for 150 ms on clicks and keys. The transcript opens in 200 ms on grid rows. Reduced motion keeps fades only.