Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

251
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda