From 3b7f7c6e3225cecac24d8edd92c403c4388583fc Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Thu, 25 Jan 2024 00:07:27 -0800 Subject: [PATCH] fix: loop until voice list available --- src/lib/components/chat/SettingsModal.svelte | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib/components/chat/SettingsModal.svelte b/src/lib/components/chat/SettingsModal.svelte index 765c20c1..c01bc4b0 100644 --- a/src/lib/components/chat/SettingsModal.svelte +++ b/src/lib/components/chat/SettingsModal.svelte @@ -618,7 +618,17 @@ gravatarEmail = settings.gravatarEmail ?? ''; speakVoice = settings.speakVoice ?? ''; - await voices.set(await speechSynthesis.getVoices()); + // await voices.set(await speechSynthesis.getVoices()); + + const getVoicesLoop = setInterval(async () => { + const _voices = await speechSynthesis.getVoices(); + await voices.set(_voices); + + // do your loop + if (_voices.length > 0) { + clearInterval(getVoicesLoop); + } + }, 100); saveChatHistory = settings.saveChatHistory ?? true;