如何将录制的音频存储在某个位置

时间:2019-07-18 12:06:41

标签: javascript

如何在目录中发送音频(blob),即/uploads/audio/audio.wav

使用recorder.js录制音频文件

function saveRecording() {
    console.log("Saving audio...");

    //disable the stop button, enable the record too allow for new recordings
    stop.disabled = true;
    record.disabled = true;
    listening.disabled = true;
    save.disabled = false;

    //tell the recorder to stop the recording
    rec.stop();

    //stop microphone access
  gumStream.getAudioTracks()[0].stop();

    //create the wav blob and pass it on to createDownloadLink
    rec.exportWAV(sendData);

    rec.clear();
}

function sendData(blob) {
    var url = URL.createObjectURL(blob);
    var au = document.createElement('audio');
    var li = document.createElement('li');
    var link = document.createElement('a');
    //add controls to the <audio> element
    au.controls = true;
    au.src = url;
    //link the a element to the blob
    link.href = url;
    link.download = 'audio-' + Date.now() + '.wav';
    link.innerHTML = link.download;
    //add the new audio and a elements to the li element
    li.appendChild(au);
    li.appendChild(link);
    //add the li element to the ordered list
    recordingsList.appendChild(li);
}

如何将audio.wav存储在另一个目录/uploads/audio/audio.wav

0 个答案:

没有答案