You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to convert some blobs chunks that will be fetched from a remote source into mp3 using this library. The problem is that the lamejs.WavHeader.readHeader seems not working. In the custom chrome extension I'm making I have this code
const processChunks = async (blobChunks) => {
console.log('chunk stream log', blobChunks);
let audioBuffer = [];
blobChunks.forEach( (chunk) => {
let wav = lamejs.WavHeader.readHeader(new DataView(chunk));
console.log(wav);
let sample = new Int16Array(chunk, wav.dataOffset, wav.dataLen / 2);
audioBuffer.push(sample);
})
sampleBlockSize = 1152;
for(var i = 0; i < audioBuffer.length; i += sampleBlockSize){
sampleChunk = audioBuffer.subarray(i, i + sampleBlockSize);
let mp3buf = mp3encoder.encodeBuffer(sampleChunk);
if(mp3buf.length > 0){
mp3Data.push(mp3buf);
}
}
// see if there's any data left
let mp3buf = mp3encoder.flush();
if(mp3buf.length > 0){
mp3Data.push(mp3buf);
}
// console.log('processed stream as mp3', mp3Data);
const output = new Blob([mp3Data], {type: 'audio/mp3'});
const fileURL = URL.createObjectURL(output);
chrome.downloads.download({
saveAs: true,
url: fileURL
}, (downloadId) => {
console.log(downloadId);
URL.revokeObjectURL(fileURL);
});
}
But I have no success. Any help?
The text was updated successfully, but these errors were encountered:
I'm trying to convert some blobs chunks that will be fetched from a remote source into mp3 using this library. The problem is that the
lamejs.WavHeader.readHeader
seems not working. In the custom chrome extension I'm making I have this codeBut I have no success. Any help?
The text was updated successfully, but these errors were encountered: