Open haylinmoore opened 5 years ago
I've had little success with mp3 files on Windows at least and end up with the same result as you.
In case you're still wondering on how to fix this issue, I would first only load wav files and convert the mp3 files to wav beforehand. You'll want to save them as wav files since loading them as mp3's will result in really messed up files that are slowed down in speed. I found my answer from looking at the save function in the code and from the answer on this Stack Overflow page: https://stackoverflow.com/questions/46623517/write-a-wav-file-in-node-js-from-an-audiobuffer.
const Audio = require('audio')
const toWav = require('audiobuffer-to-wav')
const fs = require('fs')
Audio.load('./test.wav').then(audio => {
audio.normalize()
let buffer = audio.read({
format: 'audiobuffer'
})
let wav = toWav(buffer)
fs.appendFileSync('test2.wav', new Buffer(wav))
})
Hopefully this helps you and anyone else experiencing this problem!
My code is simply
and it causes the edited-record.mp3 to be just a text file with [object ArrayBuffer] as the contents. Node version is v10.15.3 on windows 10