1.0.1 โ€ข Published 7 months ago

react-audio-recrd v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

React Student Audio Recorder

A React component for recording audio with a student-friendly UI. Features include audio compression, time limits, and a clean, intuitive interface.

Features

  • ๐ŸŽ™๏ธ Simple audio recording interface
  • โฑ๏ธ Configurable recording time limit
  • ๐Ÿ—œ๏ธ Audio compression (opus codec)
  • ๐ŸŽฏ Customizable callbacks for save/delete actions
  • ๐Ÿ“ฑ Responsive design with Tailwind CSS
  • ๐ŸŽจ Clean, intuitive UI with clear status indicators
  • โ™ฟ Accessible with ARIA labels
  • ๐Ÿงช Fully tested with Jest

Installation

npm install react-audio-recrd

Usage

import { AudioRecorder } from 'react-audio-recrd';

function App() {
  const handleSave = (blob) => {
    // Handle the recorded audio blob
    console.log('Recorded audio:', blob);
    
    // Example: Upload to server
    const formData = new FormData();
    formData.append('audio', blob, 'recording.webm');
    // fetch('/api/upload', { method: 'POST', body: formData });
  };

  const handleDelete = () => {
    // Handle deletion
    console.log('Recording deleted');
  };

  return (
    <AudioRecorder
      onSave={handleSave}
      onDelete={handleDelete}
      maxDuration={300} // 5 minutes
      compressionBitsPerSecond={96000} // 96kbps
    />
  );
}

Props

PropTypeDefaultDescription
onSave(blob: Blob) => void() => {}Callback when recording is saved
onDelete() => void() => {}Callback when recording is deleted
maxDurationnumber300Maximum recording duration in seconds
compressionFormatstring'audio/webm;codecs=opus'Audio compression format
compressionBitsPerSecondnumber96000Audio bitrate in bits per second

Browser Support

This component uses the MediaRecorder API. Check browser compatibility for support details.

The component requires these browser features:

  • MediaRecorder API
  • getUserMedia API
  • Web Audio API

Development

# Install dependencies
npm install

# Run tests
npm test

# Build package
npm run build

# Lint code
npm run lint

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

MIT ยฉ Artur Gomes

Notes

  • The component uses Opus codec for audio compression, providing good quality at low bitrates
  • Recording automatically stops when reaching maxDuration
  • Designed with accessibility in mind, including proper ARIA labels and keyboard navigation
  • Uses Tailwind CSS for styling - make sure Tailwind is configured in your project

Support

If you find any bugs or have feature requests, please create an issue in the GitHub repository.

1.0.1

7 months ago

1.0.0

7 months ago