Skip to content

Inrixia/shazamio-core

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shazamio-core

This is a fork of shazamio-core for WebAssembly

Installation

npm install shazamio-core

Types

class DecodedSignature {
	readonly number_samples: number; // Number of samples used for this signature
	readonly samplems: number; // Number of ms of audio this sample contains
	readonly uri: string; // Signature data
}

Examples

Node.js

import { recognizeBytes } from "shazamio-core";
import { readFileSync } from "fs";

const songBytes = readFileSync("./my_song.flac");
const signatures: DecodedSignature[] = recognizeBytes(songBytes);
for (const signature of signatures) {
	console.log(`This sample contains ${signature.samplems}ms of audio, ${signature.number_samples} samples.`);
	// Make sure you free an objects memory when you're done with it!
	signature.free();
	// Accessing properties of signature after freeing memory will throw an exception.
}

Web

import initShazamio, { recognizeBytes } from "shazamio-core/web";
await initShazamio();

// Get bytes from a File in browser from the user
const songBytes = new Uint8Array(await file.arrayBuffer());
const signatures: DecodedSignature[] = recognizeBytes(songBytes);

// Always free memory when done!
for (const sig of signatures) sig.free();

Methods

recognizeBytes

Recognizes an audio fingerprint fron song bytes and returns decoded signatures.

function recognizeBytes(bytes: Uint8Array, offset?: number, seconds?: number): DecodedSignature[];

Parameters

  • bytes - Bytes of the song file
  • offset - When to start sampling from in seconds
  • seconds - Seconds to sample from offset

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%