Installation
Overview
An elegant voice recording interface component that visualizes audio input with animated waveform bars, a recording timer, and smooth transitions. Perfect for voice-enabled AI applications.Features
- Animated recording toggle button
- Real-time waveform visualization with 48 animated bars
- Recording timer with mm:ss format
- Smooth state transitions
- Click to start/stop recording
- Auto-demo mode (can be disabled)
- Dark mode support
- Fully responsive design
Props
This component doesn’t expose props - it’s a complete demo implementation. The demo mode automatically cycles recording states for demonstration purposes.Component Structure
State Management
Key Features
Recording Timer: Automatically counts up while recording, formatted as “00:00”. Waveform Visualization: 48 vertical bars that animate with random heights when recording. Demo Mode: Automatically starts/stops recording for demonstration. Clicking disables demo mode.Usage Example
Basic Usage
Integration with Audio Recording
Animation Details
Recording Button
Toggle between microphone icon and spinning square:Waveform Bars
Each bar animates with a unique height and delay:Timer Format
Formats seconds into MM:SS display:Customization
Disable Demo Mode
To use this component with real recording functionality, remove the demo effect:Change Waveform Appearance
Customize Button Size
Real Implementation Notes
To implement actual voice recording:-
Request Microphone Permission
-
Create MediaRecorder
-
Handle Recording Data
-
Send to AI Service
Use Cases
- Voice Chat: AI conversation interfaces
- Voice Commands: Voice-controlled applications
- Transcription: Speech-to-text services
- Voice Notes: Recording and storing audio
- Language Learning: Pronunciation practice
Dependencies
lucide-react- Mic icon- React hooks (useState, useEffect)
@/lib/utils- cn utility
Browser Compatibility
For real audio recording, ensure browser support for:navigator.mediaDevices.getUserMedia()(most modern browsers)MediaRecorder API(Chrome 47+, Firefox 25+, Safari 14.1+)
Related Components
- AI Prompt - Text-based AI input
- AI Loading - Loading state for processing
- AI Text Loading - Simple loading indicator