Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

253
Views
Local PCM file to MP3 in Node

Im making a discord bot where currently, for 10 seconds, it reads the voice channel's audio and writes the file, though it outputs it into a pcm file rather than the desired mp3. My code is currently:

const channel = message.member.voice.channel;

        channel.join()

        const connection = await channel.join();
        const receiver = connection.receiver.createStream(message.member, {
            mode: "pcm",
            end: "silence"
        });

        setTimeout(function(){
            const writer = receiver.pipe(fs.createWriteStream('./recording.pcm'));
            writer.on('finish', () => {
                channel.leave();
            });
        },5000);

Basically, after 5 seconds from joining the channel, it leaves then writes that audio into said pcm file. I want to either write the file to mp3 from the start or have something write it into an mp3 file. I've tried node-lame but either cant seem to figure it out or it doesn't work on my windows computer. I've added this

const Lame = require("node-lame").Lame;

                const encoder = new Lame({
                    output: "./test.mp3",
                    bitrate: 192,
                }).setFile("./recording.pcm");

                encoder.encode()

right after channel.leave() but even then cant seem to figure it out. This is also based off of this forum Discord.js record MP3 of voice channel? and I've tried the ffmpeg comment they gave, but then it simply just does nothing and I have no clue to make it work like my current code.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!