Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

252
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda