Skip to content

Commit

Permalink
return resolve() in process audio
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattk70 committed Oct 20, 2024
1 parent 8950b46 commit 18b744f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions js/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ function checkBacklog() {
const backlog = sumObjectValues(predictionsRequested) - sumObjectValues(predictionsReceived);
DEBUG && console.log('backlog:', backlog);

if (backlog >= predictWorkers.length * 2) {
if (backlog >= NUM_WORKERS * 2) {
// If backlog is too high, check again after a short delay
setTimeout(() => {
resolve(checkBacklog()); // Recursively call until backlog is within limits
Expand Down Expand Up @@ -1570,8 +1570,8 @@ function processAudio (file, start, end, chunkStart, highWaterMark, samplesInBat
else {
error.message = error.message + '|' + error.stack;
}
console.log('Ffmpeg error in file:\n', file, 'stderr:\n', error)
reject(console.warn('getPredictBuffers: Error in ffmpeg extracting audio segment:', error));
console.warn('Ffmpeg error in:\n', file, 'stderr:\n', error)
reject(console.warn('processAudio: ffmpeg error:\n', file, error));
});

const STREAM = command.pipe();
Expand All @@ -1595,7 +1595,7 @@ function processAudio (file, start, end, chunkStart, highWaterMark, samplesInBat
updateFilesBeingProcessed(file)
}
DEBUG && console.log('All chunks sent for ', file);
resolve()
return resolve()
}
else {
concatenatedBuffer = concatenatedBuffer.length ? joinBuffers(concatenatedBuffer, chunk) : chunk;
Expand All @@ -1608,7 +1608,7 @@ function processAudio (file, start, end, chunkStart, highWaterMark, samplesInBat
}

// if we have a full buffer
if (concatenatedBuffer.length > highWaterMark) {
if (concatenatedBuffer.length > highWaterMark) {
const audio_chunk = concatenatedBuffer.subarray(0, highWaterMark);
const remainder = concatenatedBuffer.subarray(highWaterMark);
let noHeader = concatenatedBuffer.compare(header, 0, header.length, 0, header.length)
Expand Down Expand Up @@ -2338,7 +2338,7 @@ const parsePredictions = async (response) => {
DEBUG && console.log(`File ${file} processed after ${(new Date() - predictionStart) / 1000} seconds: ${filesBeingProcessed.length} files to go`);
}

!STATE.selection && (STATE.increment() === 0 || index === 1 ) && await getSummary({ interim: true });
!STATE.selection && (STATE.increment() === 0) && await getSummary({ interim: true });

return response.worker
}
Expand Down

0 comments on commit 18b744f

Please sign in to comment.