0

我正在尝试将 blob 数据转换为 arraybuffer。所以,我正在使用文件阅读器,但我收到错误“不支持操作”。

var audioCtx = new(window.AudioContext || window.webkitAudioContext)();
  navigator.mediaDevices.getUserMedia({audio: true}).then(function      onSuccess(stream) {
      debugger;
      rec = new MediaRecorder(stream);
      rec.ondataavailable = function(e) {
          audioChunks.push(e.data);
      };
      rec.onstart = function(e) {
          audioChunks = [];
      }
      rec.onstop = function(e) {
          var blobData = new Blob(audioChunks, {
              type: 'audio/x-l16'
          });
          debugger;
          var reader = new FileReader();
          reader.onload = function() {
              audioCtx.decodeAudioData(reader.result, function(buffer) {
                  reSample(buffer, 16000, function(newBuffer) {
                      debugger;
                      var arrayBuffer =              convertFloat32ToInt16(newBuffer.getChannelData(0));
                  });
              });
          };
          reader.readAsArrayBuffer(blobData);
      }
  }).
  catch (e = > console.log(e));
4

0 回答 0