I need to convert buffer audio file .m4a to buffer audio file .wav for send to google speech api by NodeJS
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 ...
})
})
I got error
AudioContext is not defined