diff --git a/js/ui.js b/js/ui.js index f1688e80..cc99dab7 100644 --- a/js/ui.js +++ b/js/ui.js @@ -2923,16 +2923,15 @@ function onChartData(args) { // DIAGNOSTICS: t1_analysis = Date.now(); const analysisTime = ((t1_analysis - t0_analysis) / 1000).toFixed(2); - if (! STATE.selection){ - DIAGNOSTICS['Analysis Duration'] = analysisTime + ' seconds'; - const rate = (DIAGNOSTICS['Audio Duration'] / analysisTime); - DIAGNOSTICS['Analysis Rate'] = rate.toFixed(0) + 'x faster than real time performance.'; - trackEvent(config.UUID, `${config.model}-${config.backend}`, 'Audio Duration', config.backend, Math.round(DIAGNOSTICS['Audio Duration'])); - trackEvent(config.UUID, `${config.model}-${config.backend}`, 'Analysis Duration', config.backend, parseInt(analysisTime)); - trackEvent(config.UUID, `${config.model}-${config.backend}`, 'Analysis Rate', config.backend, parseInt(rate)); - generateToast({ message:'Analysis complete.'}) - activateResultFilters(); - } + const duration = STATE.selection ? STATE.selection.end - STATE.selection.start : DIAGNOSTICS['Audio Duration']; + DIAGNOSTICS['Analysis Duration'] = analysisTime + ' seconds'; + const rate = duration / analysisTime; + DIAGNOSTICS['Analysis Rate'] = rate.toFixed(0) + 'x faster than real time performance.'; + trackEvent(config.UUID, `${config.model}-${config.backend}`, 'Audio Duration', config.backend, Math.round(duration)); + trackEvent(config.UUID, `${config.model}-${config.backend}`, 'Analysis Duration', config.backend, parseInt(analysisTime)); + trackEvent(config.UUID, `${config.model}-${config.backend}`, 'Analysis Rate', config.backend, parseInt(rate)); + STATE.selection || generateToast({ message:'Analysis complete.'}) + STATE.selection || activateResultFilters(); } /* diff --git a/js/worker.js b/js/worker.js index 83c4050e..9b820779 100644 --- a/js/worker.js +++ b/js/worker.js @@ -1287,7 +1287,7 @@ const getPredictBuffers = async ({ else { error.message = error.message + '|' + error.stack; } - reject(console.warn('Error in ffmpeg extracting audio segment:', error.message)); + reject(console.warn('getPredictBuffers: Error in ffmpeg extracting audio segment:', error.message)); }); command.on('start', function (commandLine) { DEBUG && console.log('FFmpeg command: ' + commandLine); @@ -1309,12 +1309,10 @@ const getPredictBuffers = async ({ console.log('STREAM ended, destroyed') } else { - // try/catch may no longer be necessary try { concatenatedBuffer = concatenatedBuffer.length ? Buffer.concat([concatenatedBuffer, chunk]) : chunk; } catch (error) { console.warn(error) - console.warn('concat bugger length', concatenatedBuffer.length, 'chunk.length', chunk.length, chunk.buffer.detached, concatenatedBuffer.buffer.detached) } // if we have a full buffer @@ -1403,7 +1401,7 @@ const fetchAudioBuffer = async ({ } command.on('error', error => { UI.postMessage({event: 'generate-alert', message: error.message}) - reject(new Error('Error extracting audio segment:', error)); + reject(new Error('fetchAudioBuffer: Error extracting audio segment:', error)); }); command.on('start', function (commandLine) { DEBUG && console.log('FFmpeg command: ' + commandLine); @@ -2113,11 +2111,12 @@ async function parseMessage(e) { if (remaining === 0) { if (filesBeingProcessed.length) { processNextFile({ worker: worker }); - } else if ( !STATE.selection) { - getSummary() //.then(() => UI.postMessage({event: "analysis-complete"})); - } else { - UI.postMessage({event: "analysis-complete"}); - } + } + // else if ( !STATE.selection) { + // getSummary() //.then(() => UI.postMessage({event: "analysis-complete"})); + // } else { + // UI.postMessage({event: "analysis-complete"}); + // } } } break;