Giter Club home page Giter Club logo

resemblyzer.js's Introduction

Resemblyzer.js

An recreation of CorentinJ's Resemblyzer as a Javascript module for speech analysis on the web.

What it can be used for

Given a few seconds of speech it creates a summary vector of 256 values known as an encoding. This can be used in many things such as speaker verification, deepfake detection, voice cloning, speaker diarization, and much more. The pretrained model came from the original repo and was converted to onnx to use with onnxjs. I rewrote all the preprocessing parts in javascript and took the neccessary parts from Magenta.js to convert the raw audio to mel spectrograms for the network.

Architecture

The network gets fed a batch of mels (partial mels with 160 frames each) depending on the audio length and averages the embeddings of them after it goes through 3 lstm layers and a fully connected layer with a ReLU activation. According to the original repo, it works around 1000x real-time with CUDA in python though I am not sure how it does on the gpu with ort.js.

Example

The projections of embeddings from 10 different speakers from resemblyzer in python v.s. resemblyzer.js (each speaker has 10 utterances)

Resemblyzer python Resemblyzer.js
pytorch js

Code example

You need to import tensorflow and onnxruntime. You also need the resemblyzer.min.js and the pretrained.onnx file in a folder called "Resemblyzer" in the main directory of your website.

HTML example:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>resemblyzer</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
    
    <script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.min.js"></script>
    <script src="Resemblyzer/resemblyzer.min.js"></script>
    
  </body>
</html>

Javascript example:

embed_audio("example_sentence.wav").then(function(embedding){
  //embedding is a tensor with 256 values
  embedding.print();
}

//OR using async/await

async function embed(){
  let embedding = await embed_audio("example_sentence.wav");
  embedding.print();
}
embed();

resemblyzer.js's People

Contributors

crbuch avatar

Stargazers

 avatar

Watchers

 avatar

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.