Calculate Mel-frequency cepstral coefficients (MFCCs) in the browser from prepared audio or receive live audio input from the microphone using Javascript Web Audio API.
Implement and accelerate Tensorflow 'AudioSpectrogram' and 'Mfcc' operators by compiling the TensorFlow/lite/kernels use emscripten. So it uses the same parameters as TensorFlow.
-
Download and install emscripten follow the instructions.
-
Compile each .c/.cc file to bitcode:
emcc -O3 test.cc -o test.bc
-
Compile all the .bc file to tf_mfcc.bc:
emcc *.bc -o tf_mfcc.bc
-
Compile tf_mfcc.bc to WASM:
mkdir wasm emcc -O3 -s WASM=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'cwrap']" tf_mfcc.bc -o ./wasm/mfcc.js
After compile you will get the following files int the wasm folder:
wasm ├── mfcc.js └── mfcc.wasm
-
Download release package and unzip it.
tar xzvf web-mfcc-version.tar.gz
-
Put it in to the sample folder:
example ├── favicon.ico ├── index.html ├── main.js ├── wasm │ ├── mfcc.js │ └── mfcc.wasm └── yes.wav
-
Start an http server in the example folder. You can install http-server via:
npm install http-server -g http-server
-
Open up the browser and access this URL:
-
Click on Play button to see results from console.