Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GapsDetector not returning timestamp of anomaly in NodeJS #125

Open
3 of 9 tasks
rob-richards opened this issue Jul 6, 2023 · 0 comments
Open
3 of 9 tasks

GapsDetector not returning timestamp of anomaly in NodeJS #125

rob-richards opened this issue Jul 6, 2023 · 0 comments

Comments

@rob-richards
Copy link

rob-richards commented Jul 6, 2023

What is the issue about?

  • Bug
  • Feature request
  • Usage question
  • Documentation
  • Contributing / Development

What part(s) of Essentia.js is involved?

  • essentia.js-core (vanilla algorithms)
  • essentia.js-model (machine learning algorithms)
  • essentia.js-plot (plotting utility module)
  • essentia.js-extractor (typical algorithm combinations utility)

Description

I am not getting any returned frames that contain a gap in the audio using GapsDetector. I am using Node for offline extraction. Am I missing something?

I know for sure that the audio file has gaps. I added 3 of them manually in my DAW.

Steps to reproduce / Code snippets / Screenshots

const esLib = require('essentia.js');
const wav = require('node-wav');
const fs = require('fs');

const frameSize = 2048;
const hopSize = 1024;

async function detectGapsInAudio(audioFilename) {
  try {
    const essentia = new esLib.Essentia(esLib.EssentiaWASM);

    const buffer = fs.readFileSync(audioFilename);

    const audio = wav.decode(buffer);

    const audioDataLeft = essentia.arrayToVector(audio.channelData[0]);
    const audioDataRight = essentia.arrayToVector(audio.channelData[1]);

    const audioDownMixed = essentia.MonoMixer(
      audioDataLeft,
      audioDataRight
    ).audio;

    const audioData = essentia.vectorToArray(audioDownMixed);

    const frames = essentia.FrameGenerator(audioData, frameSize, hopSize);

    const gaps = [];

    for (let i = 0; i < frames.size(); i++) {
      // Detect gaps for each frame of downmixed audio signal
      const gapsDetector = essentia.GapsDetector(
        frames.get(i),
        0.05, // attackTime
        frameSize, // frameSize
        hopSize, // hopSize
        11, // kernelSize
        3500, // maximumTime
        10, // minimumTime
        40, // postpowerTime
        -30, // prepowerThreshold
        20, // prepowerTime
        0.05, // releaseTime
        44100, // sampleRate
        -50 // silenceThreshold
      );

      if (gapsDetector.starts.size() !== 0) {
        gaps.push(gapsDetector);
      }
    }

    console.log('gaps :>> ', gaps);

    frames.delete();
    essentia.delete();
  } catch (error) {
    console.error('Catch Block Error: >> ', error);
  }
}

const audioFilename = 'audio-file.wav';
detectGapsInAudio(audioFilename);

System info

MacBook Pro M2 Max, Node.js v18.16.0

@rob-richards rob-richards changed the title GapsDetector and ClickDetector not returning timestamp of anomoly in NodeJS. GapsDetector and ClickDetector not returning timestamp of anomaly in NodeJS Jul 6, 2023
@rob-richards rob-richards changed the title GapsDetector and ClickDetector not returning timestamp of anomaly in NodeJS GapsDetector not returning timestamp of anomaly in NodeJS Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant