Skip to content

Instantly share code, notes, and snippets.

@WoolDoughnut310
Created October 28, 2022 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WoolDoughnut310/b49fad4596a8092e7f1439a90d7d039e to your computer and use it in GitHub Desktop.
Save WoolDoughnut310/b49fad4596a8092e7f1439a90d7d039e to your computer and use it in GitHub Desktop.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export default function extractFeatures(audioData: any) {
const features: number[] = [];
for (const [algorithm, identifier] of Object.entries(algorithms)) {
const algorithmFunc = essentia[algorithm];
const value = algorithmFunc.call(essentia, audioData);
if (algorithm === "KeyExtractor") {
// Parse key returns array of 2 values
features.push(...parseKey(value));
} else {
value[identifier] = Number(value[identifier].toFixed(2));
features.push(value[identifier]);
}
}
return features;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment