title: Converting a PCM file to .mp3 (Nodejs 12)
body: <p>I'm making a Discord bot and at one point I have to save an audio with the PCM format</p>
  
  <pre><code>voiceChannel.join().then(connection =&gt;
    {
      const fs = require('fs');
      // Create a ReadableStream of s16le PCM audio
      var usee = message.member;
      const audio = connection.receiver.createStream(usee, { mode: 'pcm' });
      var idAudio = makeid(10);
      audio.pipe(fs.createWriteStream(idAudio + '.pcm'));
  </code></pre>
  
  <p>(idAudio is a random generated string). The thing is that I need to convert the PCM file to MP3. I already tried to use node-lame but didn't work. I'm sure I'm missing something. The PCm is a signed 16-bit little-endian (s16le) PCM</p>
  
  <pre><code>const Lame = require("node-lame").Lame;
  
      const encoder = new Lame({
          output: "./audio-files/demox122.mp3",
          bitrate: 192
      }).setFile("./user_audio.pcm");
  
      encoder
          .encode()
          .then(() =&gt; {
              // Encoding finished
              console.error("all good");
          })
          .catch(error =&gt; {
              // Something went wrong
              console.error("error");
          });
  </code></pre>