A React component for sound detection.
You can install react-sound-detection
using npm:
npm install react-sound-detection
To use react-sound-detection
in your React application, simply import the AudioDetector
component and include it in your JSX:
import React from 'react';
import AudioDetector from 'react-sound-detection';
function App() {
const handleSoundDetected = () => {
console.log("Sound detected!");
// Do something when sound is detected
};
return (
<div>
<h1>Voice Recorder</h1>
<AudioDetector
minDecibels={-45}
onSoundDetected={handleSoundDetected}
autostart={true}
/>
</div>
);
}
export default App;
-
minDecibels
: (optional) Minimum decibel level for sound detection. Default is-45
. -
onSoundDetected
: (optional) Callback function called when sound is detected. -
autostart
: (optional) Boolean indicating whether sound detection should start automatically. Default isfalse
.