Skip to content

Commit

Permalink
added 2 sec silence in the end of the audio
Browse files Browse the repository at this point in the history
  • Loading branch information
sijumoncy committed Dec 12, 2023
1 parent b089637 commit 943aac3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
12 changes: 4 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
}
}
28 changes: 22 additions & 6 deletions renderer/src/components/AudioRecorder/core/audioUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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}`,
Expand All @@ -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');

Expand Down
1 change: 0 additions & 1 deletion renderer/src/core/burrito/importBurrito.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 943aac3

Please sign in to comment.