// Used to concatinate audio files with ffmpeg and retunrs the path to the concatinated file function concatAudioFiles(filePaths, cb) { if (filePaths.length == 1) { cb(null, filePaths[0]); } else { var ffmpegCmd = ffmpeg(); const singleFilePath = path.join(workingDir, 'article.mp3'); filePaths.forEach((x) => { ffmpegCmd.input(x); }); ffmpegCmd .setFfmpegPath(ffmpegStatic.path) .setFfprobePath(ffprobeStatic.path) .on('error', (err) => { cb(err, null); }) .on('end', () => { cb(null, singleFilePath); }) .mergeToFile(singleFilePath, workingDir); } }