Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Promise.all(promises).then(function(allBuffers) {
let merger = new Crunker();
try {
let output = merger.export(merger.concatAudio(allBuffers), "audio/wav");
that.updateSession(payload,function(session) {
if (!session.audio) session.audio=[];
that.blobToDataUrl(output.blob).then(function(dataUrl) {
session.audio.push(dataUrl);
// start again
that.resetAudioBuffer(siteId);
that.setLogData();
});
return session;
});
} catch (e) {
console.log(e.message);
}
});
React.useEffect(() => {
if (crunkerRef.current) {
let audio = new Crunker();
audio
.fetchAudio(oldAudioFileUrl, newAudioFileUrl)
.then(buffers => audio.mergeAudio(buffers))
.then(merged => audio.export(merged, 'audio/wav'))
.then(output => {
const file_reader = new FileReader();
const dateOfRecording = Date.now();
file_reader.readAsDataURL(output.blob);
file_reader.onloadend = async function() {
const base64_string = file_reader.result;
uploadAudio(base64_string, author, chatId, dateOfRecording);
return base64_string;
};
setConsolidatedAudioFileName(`${chatId}-${dateOfRecording}-${author}.webm`);
setTimeout(() => setConsolidationDone(true), 1500);
})