title: How to change audio file codec in javascript
body: <p>I'm gathering audio from the browser using MediaRecorder and the audio file being produced has a codec that is incompatible with IBM Watson Speech to Text. The codec is "matroska" and I need it to be raw PCM codec.</p>
  
  <p>How do I set the codec of an audio file that I'm gathering from the browser? Here's some of the code that I'm using:</p>
  
  <pre><code>var options = {
    audioBitsPerSecond : 32000
  }
  var mediaRecorder = new MediaRecorder(audioStream, options);
  mediaRecorder.start();
  
  var data = [];
  mediaRecorder.ondataavailable = e =&gt; console.log(mediaRecorder.audioBitsPerSecond);
  mediaRecorder.ondataavailable = e =&gt; e.data.size &amp;&amp; data.push(e.data);
  mediaRecorder.onstop = () =&gt; process(data);
  
  function process(data) {
    var int16Array = [];
    const blob = new Blob(data, {
      type: 'audio/wav'
    })
  </code></pre>