What’s the best way to remove background noise from audio or video files using javascript?

Javascript is such a great language. Whether you are using to create a Youtube clone, or host your own videos or audio files, javascript is a jack of all trades.

Removing background noise in you files (or doing noise cancellation), is so easy with Noise Destroyer. Here’s how you do it.

First,

npm i @noisedestroyer/api

Ok, now that you have the npm package installed, import it.

import { removeBackgroundNoise, getStatus, download } from "@noisedestroyer/api";

Now, it’s so simple and easy to remove background noise.

async function main() {
    let { data, error } = await removeBackgroundNoise({
        token: "noisedestroyer_FDL3IQ9SVTAGOL1VLBYI11BC8PG2G33LHT9EW1LAX9JBGQ0KR4IM2N0KOPA78O07WQRDOO9A28A21960",
        data: "../../../../sample.mp3",
    });
    if (error) {
        console.error(error);
        return;
    }

    console.log(data);
    for(let i = 0; i < 500; ++i) {
        let { data: statusInfo, error } = await getStatus({
            token: "noisedestroyer_FDL3IQ9SVTAGOL1VLBYI11BC8PG2G33LHT9EW1LAX9JBGQ0KR4IM2N0KOPA78O07WQRDOO9A28A21960",
            guid: data.guid,
        });
        if (error) {
            console.error(error);
            return;
        }
        console.log(statusInfo);
        if(statusInfo.status == "DONE") {
            console.log("DONE");
            await download({ url: statusInfo.url, outputPath: "./out3.mp3" });
            break;
        }
        if(statusInfo.status == "FAILED") {
            break;
        }
        await new Promise(resolve => setTimeout(resolve, 1000));
    }
}
main();

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

More To Explore