Git Product home page Git Product logo

web-mfcc's Introduction

Web-MFCC

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.

Compile the code

  1. Download and install emscripten follow the instructions.

  2. Compile each .c/.cc file to bitcode:

    emcc -O3 test.cc -o test.bc
    
  3. Compile all the .bc file to tf_mfcc.bc:

    emcc *.bc -o tf_mfcc.bc
    
  4. 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
    

Run the example

  1. Download release package and unzip it.

    tar xzvf web-mfcc-version.tar.gz
    
  2. Put it in to the sample folder:

    example
    ├── favicon.ico
    ├── index.html
    ├── main.js
    ├── wasm
    │   ├── mfcc.js
    │   └── mfcc.wasm
    └── yes.wav
    
  3. Start an http server in the example folder. You can install http-server via:

    npm install http-server -g
    
    http-server
    
  4. Open up the browser and access this URL:

    http://localhost:8080/

  5. Click on Play button to see results from console.

web-mfcc's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

pixelami

web-mfcc's Issues

Strange results - more details about 'getAudioPCMData' and a reference graph?

Hi @miaobin

this is very interesting work 👍 and I've been planning to integrate it into an audio library for SEPIA I'm working on as a replacement for Meyda MFCC to gain some WASM speed 😀 ... but the results seem a bit confusing 😅

Here is a screenshot comparing Web-MFCC (1, 3) to Meyda MFCC (2):

image

In graph 1 and 2 I've used the same chunked buffer to create the MFCC step-by-step. 1 is Web-MFCC and 2 is Meyda. In graph 3 I've used Web-MFCC on the same buffer but as one big step and not in chunks. In graph 3 I've also removed the first and every 13th entry of the result array, which leads me to my first question:

  1. What exactly is the result of getAudioPCMData as seen in your example? Looking at my results it almost seems like the first entry of every block (1 block = number of MFCCCoefficients = 13) is the sum of the signal instead of a coefficient.

  2. Did you check the results against any reference? Comparing Meyda (2) and the cleaned-up Web-MFCC (3) the Web-MFCC result looks scrambled somehow. Now the parameters might not be exactly the same (I've tried to get as close as possible) but I'm pretty sure there is something else going on.

Btw I've used a recording of "yes ... no ... yes" for my graphs.

Any comment or help to get the results fixed would be appreciated 🙂

Ty,
Florian

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.