This repository contains a modular JavaScript-based Voice Activity Detection (VAD) WebApp that uses the Web Audio API to analyze audio input from the microphone and detect when a user is speaking.
speak2.mp4
- Real-time voice activity detection using the user's microphone.
- Modular JavaScript for easy customization and expansion.
- Example HTML page to demonstrate functionality.
- CSS file for basic styling.
- A modern web browser that supports ES6+ and the Web Audio API.
- A web server to serve the files (local or remote).
To set up the Voice Activity Detection WebApp on your local environment, follow these steps:
- Clone the repository to your local machine.
- Ensure you have a web server running. You can use server software like Apache, Nginx, or development tools like Python's
http.server
or Node.js'shttp-server
. - Place the files within the web server's serving directory.
- Access the
index.html
file through the web server (not directly via the file system to ensuregetUserMedia
works correctly).
Open the index.html
file in your web browser. You should be prompted to allow microphone access. Once access is granted, the app will start detecting voice activity and update the status message on the page accordingly.
The sensitivity of the voice activity detection can be adjusted by changing the speakingThreshold
parameter. This is the volume level above which speech is considered to be detected. The default value is set to 5
. To adjust the sensitivity, pass a different threshold value when initializing the SpeechDetection
class in main.js
:
// Set your desired speaking threshold here
// Higher for less sensitivity, lower for more
const customSpeakingThreshold = 5; // Change this value to your preferred threshold
// Initialize the SpeechDetection class with the onUpdate callback
const speechDetection = new SpeechDetection({
onUpdate: onUpdate
});
By adjusting the customSpeakingThreshold
value, you can tailor the sensitivity of the detection to the needs of your specific environment or application.
To expand upon this code for different applications:
- Modify
SpeechDetection.js
to add more functionality to the voice detection, such as custom callbacks or events when voice is detected or when it stops. - Update
main.js
to handle different application logic, such as starting and stopping the detection based on user input. - Style the application by editing
style.css
. - Implement additional UI elements or indicators for voice activity, as desired.
Contributions are welcome! If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.