title: recorder.js to node to azure speaker recognition
body: <p>I have a browser app which records the user's voice through their microphone and exports to a WAV file using recorder.js. I think convert that to a data url and post it to node. I then try to send the audio to the Microsoft Azure Speaker Recognition API but I always get "Invalid Audio Format: Not a WAVE file - no RIFF header" back. </p>
  
  <p>Is there a way to add a RIFF header or is there something about recorder.js or converting to and from base64 which removes these headers? Is there a way to add them back in?</p>
  
  <p>The code:
  INDEX.HTML</p>
  
  <pre><code>rec.exportWAV(function (blob) {
      var reader = new window.FileReader();
      reader.readAsDataURL(blob);
      reader.onloadend = function () {
          base64 = reader.result;
          console.log(base64)
          $.ajax({
              type: "POST",
              url: '/addVoiceToProfile',
              data: { userId: '', voiceId: "XXX-XXX", voice: base64, sampleRate: audioContext.sampleRate / 1000 },
              success: function (results) {
                  console.log(results)
              }
          })
      }
  })
  </code></pre>
  
  <p>NODE ROUTE:</p>
  
  <pre><code>app.post('/addVoiceToProfile', function(req, res){
      var voicedata = req.body.voice;
      var base64Data = voicedata.replace(/^data:([A-Za-z-+/]+);base64,/, '');
      addVoicesToProfile(base64Data, req.body.voiceId).then(function(results){
          res.send(results)
      })
  })
  </code></pre>
  
  <p>addVoicesToProfile:</p>
  
  <pre><code>function addVoicesToProfile(voice, id, user){
      return new Promise(function (resolve, reject) {
          var url = AzureParameters.endPoint+"/spid/v1.0/verificationProfiles/"+id+"/enroll";
          request({
              url:url,
              headers:{'Content-Type':'audio/wave', 'Ocp-Apim-Subscription-Key':AzureParameters.key},
              body: Buffer.from(voice, 'base64').toString('binary'),
              method: "POST",
              json: true
          }, function(err, response, body){
              if(err) return reject(err);
              return resolve(body)
          })
      })
  }
  </code></pre>