From 943aac3923503ab9445d9e2ece3910e2df734ac3 Mon Sep 17 00:00:00 2001 From: sijumoncy <72241997+sijumoncy@users.noreply.github.com> Date: Tue, 12 Dec 2023 18:23:39 +0530 Subject: [PATCH] added 2 sec silence in the end of the audio --- .vscode/settings.json | 12 +++----- .../AudioRecorder/core/audioUtils.js | 28 +++++++++++++++---- renderer/src/core/burrito/importBurrito.js | 1 - 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 0ecec27ec..ad081d03a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,15 +2,11 @@ "[javascript]": { "editor.formatOnSave": false }, - "editor.rulers": [ - 100 - ], + "editor.rulers": [100], "editor.fontLigatures": true, "prettier.tabWidth": 4, "eslint.alwaysShowStatus": true, - "prettier.disableLanguages": [ - "js" - ], + "prettier.disableLanguages": ["js"], "prettier.useTabs": true, "editor.formatOnSave": true, "editor.multiCursorModifier": "alt", @@ -27,8 +23,8 @@ "eslint.codeAction.disableRuleComment": {}, "eslint.codeAction.showDocumentation": {}, "editor.codeActionsOnSave": { - "source.fixAll.eslint": true + "source.fixAll.eslint": "explicit" }, "eslint.workingDirectories": [], "editor.tabSize": 2 -} \ No newline at end of file +} diff --git a/renderer/src/components/AudioRecorder/core/audioUtils.js b/renderer/src/components/AudioRecorder/core/audioUtils.js index b33234637..a8b68af27 100644 --- a/renderer/src/components/AudioRecorder/core/audioUtils.js +++ b/renderer/src/components/AudioRecorder/core/audioUtils.js @@ -34,11 +34,12 @@ async function generateTimeStampData(buffers, book, chapter) { const currentVerse = `Verse_${(index + 1).toString().padStart(2, 0)}`; const startTimeString = sec_to_min_sec_milli_convertor(start)[3]; let durationString; + const silenceDuration = 2; let offset = 0; if (index === 0 || (index === buffers.length - 1)) { - // adding this because of 1 sec silence in the start || 1 sec silence in the end add it to last verse - durationString = sec_to_min_sec_milli_convertor(buffer.duration + 1)[3]; - offset = 1; + // adding this because of 2 sec silence in the start || 2 sec silence in the end add it to last verse + durationString = sec_to_min_sec_milli_convertor(buffer.duration + silenceDuration)[3]; + offset = silenceDuration; } else { offset = 0; durationString = sec_to_min_sec_milli_convertor(buffer.duration)[3]; @@ -106,10 +107,9 @@ export async function mergeAudio(audioArr, dirPath, path, book, chapter, extensi commandArr.push( ...inputCmdArr, '-filter_complex', - `aevalsrc=0:d=1[silence1];[silence1]${filterStr}`, + `aevalsrc=0:d=2[silence1];[silence1]${filterStr}`, '-map', '[out]', - ...audioMetaDataArr, '-ar', '48000', `output.${extension}`, @@ -122,8 +122,24 @@ export async function mergeAudio(audioArr, dirPath, path, book, chapter, extensi // exeute merge process await ffmpeg.exec(commandArr); + // add end 2 sec to the create audio + await ffmpeg.exec([ + '-i', + `output.${extension}`, + '-filter_complex', + 'aevalsrc=0:d=2[silenceEnd];[0:0][silenceEnd]concat=n=2:v=0:a=1[outEnd]', + '-map', + '[outEnd]', + ...audioMetaDataArr, + '-ar', + '48000', + `outputMerged.${extension}`, + ]); + + // write the audio back and convert + // generate unit8 buffer out - const fileData = await ffmpeg.readFile(`output.${extension}`); + const fileData = await ffmpeg.readFile(`outputMerged.${extension}`); logger.debug('audioUtils.js', 'mergeAudio : audio merged buffer created'); diff --git a/renderer/src/core/burrito/importBurrito.js b/renderer/src/core/burrito/importBurrito.js index 431099e4e..ed194c9b4 100644 --- a/renderer/src/core/burrito/importBurrito.js +++ b/renderer/src/core/burrito/importBurrito.js @@ -96,7 +96,6 @@ export const viewBurrito = async (filePath, currentUser, resource) => { sb = JSON.stringify(metadata); } const success = await validate('metadata', path.join(filePath, 'metadata.json'), sb, metadata.meta.version); - console.log({ metadata }); if (success || metadata.type?.flavorType?.flavor?.name === 'audioTranslation') { result.validate = true; logger.debug('importBurrito.js', 'Burrito file validated successfully');