Skip to Content
ComponentsVoiceVisualizer

VoiceVisualizer

A visual audio level indicator that displays animated bars during voice conversations. Used internally by VoiceAgent but can be used standalone in custom UIs.

Import

import { VoiceVisualizer } from '@vocobase/voice-client-sdk' import '@vocobase/voice-client-sdk/styles.css'

Basic Usage

The visualizer must be used within a VoiceSessionProvider and only displays when a session is active:

import { VoiceSessionProvider, VoiceVisualizer, useVoiceSession, useConnectionState } from '@vocobase/voice-client-sdk' function App() { return ( <VoiceSessionProvider apiKey="..." agentName="..."> <CustomUI /> </VoiceSessionProvider> ) } function CustomUI() { const { connect, disconnect } = useVoiceSession() const { isConnected } = useConnectionState() return ( <div> <button onClick={isConnected ? disconnect : connect}> {isConnected ? 'End' : 'Start'} </button> {isConnected && ( <VoiceVisualizer options={{ barCount: 20, barColor: '#3b82f6' }} /> )} </div> ) }

Props

PropTypeDescription
optionsVisualizerOptionsCustomize the visualization appearance
classNamestringAdditional CSS classes

Options

interface VisualizerOptions { barCount?: number // Number of bars to display barColor?: string // CSS color for the bars barGap?: number // Space between bars (px) barWidth?: number // Width of each bar (px) barMaxHeight?: number // Maximum bar height (px) }

Default Values

OptionDefault
barCount30
barColor"#ffffff"
barGap3
barWidth4
barMaxHeight60

Examples

Minimal Blue Visualizer

<VoiceVisualizer options={{ barCount: 15, barColor: '#3b82f6' }} />

Wide Green Bars

<VoiceVisualizer options={{ barCount: 10, barColor: '#10b981', barWidth: 12, barGap: 6, barMaxHeight: 100 }} />

How It Works

The visualizer connects to the audio stream from the voice session and displays real-time audio levels:

  1. Audio data is captured from both user microphone and agent response
  2. Frequency data is analyzed in real-time
  3. Bar heights are mapped to frequency bands
  4. Smooth animations interpolate between audio samples

The visualization is purely visual feedback — it doesn’t affect the audio stream.

Last updated on