This is a fork of shazamio-core for WebAssembly
npm install shazamio-core
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
}
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.
}
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();
Recognizes an audio fingerprint fron song bytes and returns decoded signatures.
function recognizeBytes(bytes: Uint8Array, offset?: number, seconds?: number): DecodedSignature[];
-
bytes
- Bytes of the song file -
offset
- When to start sampling from in seconds -
seconds
- Seconds to sample from offset