我需要转换缓冲音频文件.m4a的缓冲音频文件.WAV用于发送给Google通过的NodeJS转换.M4A为.wav
var toWav = require('audiobuffer-to-wav')
var xhr = require('xhr')
var context = new AudioContext()
// request the MP3 as binary
xhr({
uri: 'audio/track.mp3',
responseType: 'arraybuffer'
}, function (err, body, resp) {
if (err) throw err
// decode the MP3 into an AudioBuffer
audioContext.decodeAudioData(resp, function (buffer) {
// encode AudioBuffer to WAV
var wav = toWav(buffer)
// do something with the WAV ArrayBuffer ...
})
})
我有错误
AudioContext is not defined
然后会发生什么? – TGrif
所以我尝试使用audiobuffer-to-wav但是AudioContext()是错误的 – otaroo
具体是什么错误? – TGrif