Skip to content

AudiogenAI/waveform-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

waveform-rs

image

WASM package to create Waveforms in-browser, processing takes around 1-2ms for most samples as opposed to 20-50ms in raw JS

Supports all codecs except for MKV (.webm), thanks to amazing Project Symfonia

Installation

Available on NPM.js

npm i --save-dev waveform-rs

Usage

You need to proc the init() method which calls WebAssembly.instantiate, it can be wrapped as below to avoid snake_case'ing

import init, { audio_to_waveform } from "waveform-rs";

const processAudioData = async (
  data: Uint8Array,
  samplesPerSecond?: number,
): Promise<Float32Array> => {
  await init();
  const waveform = audio_to_waveform(data, samplesPerSecond);
  return waveform;
};

In case you are dealing with blobs, you can, the file format is going to be determined automatically

const response = await fetch(sample);
const arrayBuffer = await response.arrayBuffer();
const data = await processAudioData(
  new Uint8Array(arrayBuffer),
  samplesPerSecond,
);

About

generate waveform from any audio file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages