A web based audio noise cancellation demo using WebAssembly translated from Xiph/Rnnoise, a recurrent neural netork based noise reduction library in C++. The C++ library and Wasm web-version accepts raw audio streams in Float32Arrays and applies denoising based on an included RNN model. Xiph/Rnnoise native has re training capabilities and option to provide custom models for de-noising.
WebAssembly modules and HTML/JS glue code is provided. The web demo makes use of WebAudio for capturing audio stream through the browser and decoding WAV audio files. Browser support for WebAudio expected.
- Python 2.7 or above on the local machine and Python executable in Env path.
- WebAudio and Wasm supported web-browser (preferrably Edge/Chrome/Firefox)
- Download / Clone contents of this repo to a local directory.
- Navigate to the directory containing AudioStream.html.
- Run
python -m SimpleHTTPServer
from a Terminal/Command prompt. - Navigate to Http://localhost:8080
- Click on AudioStream.html
- Click on 'Start Recording' and allow microphone access if prompted. This will record audio including ambient noise.
- Click 'Stop Recording' once finished.
- Alternatively Upload any single channel wav audio file for denoising pre recorded files.
- Use 'Play Recording' or 'Play Denoised' buttons to playback recorded audio and denoised audio respectively.
The C++ source of the demo is included in 'Examples' directory.
To modify
- Replace contents of 'rnnoise/examples' with the code in 'Examples' directory.
- Follow instructions from in the submodule to build Native demo.
- Use emscripten to build the Web demo.
Example: emcc -g -O3 -s ALLOW_MEMORY_GROWTH=1 -s EXPORT_ALL=1 -s EXTRA_EXPORTED_RUNTIME_METHODS='["cwrap"]' -I ../include/ ../src/*.c ../examples/*.c -o rnn_denoise.js
To optimize for worklets: emcc -g -O3 -s BINARYEN_ASYNC_COMPILATION=0 -s SINGLE_FILE=1 -s ALLOW_MEMORY_GROWTH=1 -s EXTRA_EXPORTED_RUNTIME_METHODS='["cwrap"]' -I ../include/ ../src/*.c ../examples/*.c --post-js denoise-worklet.js -o denoise-wasm-worklet.js