This topic was automatically generated from Slack. You can find the original thread here.
Hello. I posted this on the Pipedream Community page yesterday but have since learnt that Discord is where the action is. I’m having massive issues getting audio to parse through NPM packages.
import fs from "fs/promises";
import * as mm from "music-metadata";
export default defineComponent({
props: {
audioFilePath: {
type: "string",
label: "Audio File Path",
description: "Path of the audio file to extract metadata from",
},
},
async run() {
const buffer = await fs.readFile(this.audioFilePath);
const metadata = await mm.parseBuffer(buffer, 'audio/mpeg', { duration: true });
const artist = metadata.common.artist;
const title = metadata.common.title;
console.log('Artist:', artist);
console.log('Title:', title);
return { artist, title };
},
});
In this instance, we’re logging the artist and title to the console to validate that the file isn’t parsing through the package - and guess what, it isn’t. I’ve tried lots of different NPM options - FFProbe, JSMediaTags, ID3tags… you name it - I can’t get any of them to parse the file correctly.
The code executes - but the ‘artist’ and ‘title’ both log as ‘undefined’. I tried a different approach, using the parseFile statement below - but the result was the same.
import * as mm from "music-metadata";
export default defineComponent({
props: {
audioFilePath: {
type: "string",
label: "Audio File Path",
description: "Path of the audio file to extract metadata from",
},
},
async run() {
const metadata = await mm.parseFile(this.audioFilePath, { duration: true });
const artist = metadata.common.artist;
const title = metadata.common.title;
console.log('Artist:', artist);
console.log('Title:', title);
return { artist, title };
},
});
No, I haven’t - I’m massive n00b at’s basically been using ChatGPT4 and posting HTTP requests to your AI - but your suggestion was on my list of things to try
I think that’s one way to go. I suspect that your file in invalid and/or you downloaded the file to tmp dir but referred to it incorrectly in to audioFilePath
It would be better if you have coding knowledge to understand what it’s doing and what’s wrong. If you’re still unsure that you can implement your usecase, you can: