@sorisdk/matcher
v0.1.5
Published
Browser WASM SDK for audio fingerprint matching
Maintainers
Readme
@sorisdk/matcher
WebAssembly package for matching fingerprint bytes against pack data in the browser.
Most web integrations should use @sorisdk/web-audio for a simpler end-to-end flow. This package is intended for lower-level cases where you want to control fingerprint generation and matching yourself.
Public integration guide: https://docs.soriapi.com/ko/integration/web
Installation
npm install @sorisdk/matcherVite-based apps need vite-plugin-wasm.
The default loader is intended to work in both Vite dev/build and Nuxt client production bundles. If you need to override wasm loading explicitly, pass either:
loader: () => import("@sorisdk/matcher/generated/core.js")wasmModule: await import("@sorisdk/matcher/generated/core.js")
Minimal example
import { MatcherSession, AudioFingerprintType, initMatcher } from "@sorisdk/matcher";
await initMatcher();
const session = new MatcherSession();
await session.ready();
await session.addEntry(
"demo-track",
AudioFingerprintType.Livestream,
new Uint8Array([1, 2, 3])
);
const result = await session.match(new Uint8Array([1, 2, 3]));
console.log(result.best);
console.log(await session.getEntryMetadata("demo-track"));Advanced wasm loading
import { MatcherSession, initMatcher } from "@sorisdk/matcher";
await initMatcher({
loader: () => import("@sorisdk/matcher/generated/core.js")
});
const session = new MatcherSession({
wasmModule: await import("@sorisdk/matcher/generated/core.js")
});Pack loading
loadPack(...) accepts:
Uint8ArrayArrayBufferBlobResponseRequeststringURL
If you want campaign events and browser recognition flow on top of matching, use @sorisdk/web-audio.
Metadata lookup
Audiopack footer metadata is available through explicit lookup rather than being
embedded in MatchResult.
const best = await session.bestMatch(queryBytes);
const metadata = best ? await session.getEntryMetadata(best.name) : null;