You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const{ Model, decodeAudio }=require('clap-cpp');constmodel=newModel('/path/to/model.gguf',4);try{console.log(model.projectionDimension,model.audioSampleRate);consttext=model.text('a piano playing');// owned Float32Arrayconst{ samples, sampleRate }=decodeAudio('/path/to/audio.wav');constaudio=model.audio(samples,sampleRate);// automatically resampled// CLAP projections are unit-normalized, so their dot product is cosine.constsimilarity=text.reduce((sum,x,i)=>sum+x*audio[i],0);console.log(similarity);}finally{model.close();// optional early release; garbage collection also frees weights}