be more cautious about pre-caching prompts; in particular, a Config verb will not give us time to precache so avoid in that scenario (#720)

This commit is contained in:
Dave Horton
2024-04-15 15:38:10 -04:00
committed by GitHub
parent 7da11df88e
commit e322b7d8d3

View File

@@ -1598,7 +1598,23 @@ Duration=${duration} `
} }
_preCacheAudio(newTasks) { _preCacheAudio(newTasks) {
for (const task of newTasks) { /**
* only precache audio for the a queued say if we have one or more non-Config verbs
* ahead of it in the queue. This is because the Config verb returns immediately
* and would not give us enough time to generate the audio. The point of precaching
* is to take advantage of getting the audio in advance of being needed, so we need
* to be confident we have some time before the say verb is executed, and the Config
* does not give us that confidence since it returns immediately.
*/
const allTasks = (this.tasks || []).concat(newTasks);
const skipFirst = allTasks.slice(1);
const idxFirstNotConfig = skipFirst.findIndex((t) => t.name !== TaskName.Config);
if (-1 === idxFirstNotConfig) return;
const allTasksAfterFirstNotConfig = skipFirst.slice(idxFirstNotConfig);
for (const task of allTasksAfterFirstNotConfig) {
if (task.name === TaskName.Config && task.hasSynthesizer) { if (task.name === TaskName.Config && task.hasSynthesizer) {
/* if they change synthesizer settings don't try to precache */ /* if they change synthesizer settings don't try to precache */
break; break;