meyda icon indicating copy to clipboard operation
meyda copied to clipboard

Some feature extractors not working in CLI version

Open Oortone opened this issue 3 years ago • 8 comments

Describe the bug The following feature extractors, taken from this listing, does not produce numerical results on a wav 22 kHz sampling frequency when directing the result to a csv-file

complexSpectrum
loudness
spectralFlux

In the first to cases the resulting file is filled with rows like this:

loudness
undefined,undefined,
undefined,undefined,
undefined,undefined,
...

However these commands prodcues numerical results on screen when not writing to file.

In the case of spectralFlux I get an error:

Starting extraction...
|Sample rate recognized as: 22050
/usr/local/lib/node_modules/meyda/dist/node/main.js:590
        throw new TypeError();
        ^

TypeError
    at Object.spectralFlux (/usr/local/lib/node_modules/meyda/dist/node/main.js:590:15)
    at extract (/usr/local/lib/node_modules/meyda/dist/node/main.js:1239:52)
    at /usr/local/lib/node_modules/meyda/dist/node/main.js:1258:30
    at Array.reduce (<anonymous>)
    at Object.extract (/usr/local/lib/node_modules/meyda/dist/node/main.js:1255:28)
    at extractFeatures (/usr/local/lib/node_modules/meyda/bin/cli.js:105:22)
    at /usr/local/lib/node_modules/meyda/bin/cli.js:148:9
    at Reader.<anonymous> (/usr/local/lib/node_modules/meyda/bin/wav-loader.js:60:17)
    at Reader.emit (events.js:182:13)
    at readableAddChunk (/usr/local/lib/node_modules/meyda/node_modules/readable-stream/lib/_stream_readable.js:195:16)

To Reproduce Issue following commands in Terminal/Console: meyda file01.wav --o=file01.csv spectralFlux meyda file01.wav --o=file01.csv complexSpectrum meyda file01.wav --o=file01.csv loudness

Expected behavior Csv files as in the other cases

Environment configuration CLI version on macOS 10.14

Oortone avatar Nov 15 '21 14:11 Oortone

Thanks! Does this happen on any wav at that sample rate? If so, it would be great if you could provide one.

The bug with Spectral Flux is known and we're working on that in the next major release. The problem is that the fix of that bug contains a breaking change, so we can't release it on the v5 version, and I've been slow merging it because I hadn't been able to get a code review. But we've made a beta available - if you install [email protected], you'll get a working spectral flux (though it is actually incorrect, but there'll be a -beta.3 soon with a fix to that.

But undefined for complex spectrum and loudness is definitely fishy and we'll look into it. Thanks for the report!

hughrawlinson avatar Nov 15 '21 17:11 hughrawlinson

Also it looks like you're still using that temporary site for reference docs - I just wanted to let you know that we've published those improved docs to our regular site now :)

hughrawlinson avatar Nov 16 '21 08:11 hughrawlinson

Hello. I get this regardless of sample rate. Here are two example files at two different sample rates. Meyda reports the correct sample rate in both cases. files.zip

Console output looks ok, but the files produced using --o flag are all filled with undefined.

Oortone avatar Nov 16 '21 15:11 Oortone

ah ok! I'll take a look, thanks :)

hughrawlinson avatar Nov 16 '21 21:11 hughrawlinson

Note for myself: This is likely because we don't distinguish between objects and arrays when rendering the output for csv here

hughrawlinson avatar Nov 16 '21 21:11 hughrawlinson

@Oortone I think some of your problems would be solved if you got the output from meyda in json and then used something like this to convert the JSON to CSV in a more reliable way?

hughrawlinson avatar Nov 16 '21 21:11 hughrawlinson

OK, thanks. I might have a look at that. Although I don't think I need these features. Just happened to find the bug.

Oortone avatar Nov 17 '21 19:11 Oortone

Ah cool, thanks!

hughrawlinson avatar Nov 17 '21 20:11 hughrawlinson