diff --git a/recipes/llm-voice-assistant/web/package.json b/recipes/llm-voice-assistant/web/package.json index 88fa6e7..207fc26 100644 --- a/recipes/llm-voice-assistant/web/package.json +++ b/recipes/llm-voice-assistant/web/package.json @@ -21,7 +21,7 @@ "dependencies": { "@picovoice/cheetah-web": "^2.0.0", "@picovoice/orca-web": "^1.0.0", - "@picovoice/picollm-web": "~1.2.0", + "@picovoice/picollm-web": "~1.2.3", "@picovoice/porcupine-web": "^3.0.3", "@picovoice/web-voice-processor": "^4.0.9" }, diff --git a/recipes/llm-voice-assistant/web/public/controller.js b/recipes/llm-voice-assistant/web/public/controller.js index fb59753..d4e6255 100644 --- a/recipes/llm-voice-assistant/web/public/controller.js +++ b/recipes/llm-voice-assistant/web/public/controller.js @@ -96,6 +96,7 @@ window.onload = () => { let audioStream; let streamCalls = 0; let isDetected = false; + let isResponding = false; try { await Picovoice.init(accessKey.value, @@ -106,6 +107,8 @@ window.onload = () => { { onDetection: () => { isDetected = true; + isResponding = false; + audioStream.clear(); message.innerText = "Wake word detected, utter your request or question..."; humanElem = startHumanMessage(); }, @@ -115,6 +118,7 @@ window.onload = () => { }, onEndpoint: () => { isDetected = false; + isResponding = true; message.innerHTML = "Generating
say `Picovoice` to interrupt"; llmElem = startLLMMessage(); }, @@ -122,14 +126,17 @@ window.onload = () => { addMessage(llmElem, text); }, onStream: (pcm) => { - audioStream.stream(pcm); - if (streamCalls > 1) { - audioStream.play(); - } else { - streamCalls++; + if (isResponding) { + audioStream.stream(pcm); + if (streamCalls > 1) { + audioStream.play(); + } else { + streamCalls++; + } } }, onComplete: async (interrupted) => { + isResponding = false; audioStream.play(); if (interrupted && isDetected) { audioStream.clear(); diff --git a/recipes/llm-voice-assistant/web/yarn.lock b/recipes/llm-voice-assistant/web/yarn.lock index 8312aaf..3812d60 100644 --- a/recipes/llm-voice-assistant/web/yarn.lock +++ b/recipes/llm-voice-assistant/web/yarn.lock @@ -931,10 +931,10 @@ dependencies: "@picovoice/web-utils" "=1.4.2" -"@picovoice/picollm-web@~1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@picovoice/picollm-web/-/picollm-web-1.2.0.tgz#346a62a81acb5f53073075766a036060daa9a512" - integrity sha512-vjnjrC30auuNBmpLu2plNk7BzSNtGKOWhx5+X6IHQYfVt00CnK23fYLxzS16CR6thGSinEixC44H61bgJLT4Ug== +"@picovoice/picollm-web@~1.2.3": + version "1.2.3" + resolved "https://registry.yarnpkg.com/@picovoice/picollm-web/-/picollm-web-1.2.3.tgz#765f52c55943c71dbb7c95492b93cda15e483999" + integrity sha512-QtiZTckN6UDlO5bVnR5ldhegb9h63szu4l3PknI7V4Qsz8w4AXaloRXlnOhK87oEC5Px2C56ve7+aiH9oSPcNQ== dependencies: "@picovoice/web-utils" "~1.4.3"