[WIP] AWS Nova Sonic service - just for safety, add a short delay after BotStoppedSpeaking before sending LLMFullResponseEndFrame + TTSStoppedFrame, to give a bit of leeway for the LLM to deliver the "FINAL" text block describing what was said
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
# SPDX-License-Identifier: BSD 2-Clause License
|
# SPDX-License-Identifier: BSD 2-Clause License
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import base64
|
import base64
|
||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
@@ -211,7 +212,8 @@ class AWSNovaSonicLLMService(LLMService):
|
|||||||
|
|
||||||
async def _handle_bot_stopped_speaking(self):
|
async def _handle_bot_stopped_speaking(self):
|
||||||
if self._assistant_is_responding:
|
if self._assistant_is_responding:
|
||||||
# Consider the assistant finished with their response.
|
# Consider the assistant finished with their response (after a short delay, to allow for
|
||||||
|
# any FINAL text block to come in).
|
||||||
#
|
#
|
||||||
# TODO: ideally we could base this solely on the LLM output events, but I couldn't
|
# TODO: ideally we could base this solely on the LLM output events, but I couldn't
|
||||||
# figure out a reliable way to determine when we've gotten our last FINAL text block
|
# figure out a reliable way to determine when we've gotten our last FINAL text block
|
||||||
@@ -224,6 +226,7 @@ class AWSNovaSonicLLMService(LLMService):
|
|||||||
# FINAL text blocks to know how many or which FINAL blocks to expect, but user
|
# FINAL text blocks to know how many or which FINAL blocks to expect, but user
|
||||||
# interruptions throw a wrench in these schemes: depending on the exact timing of the
|
# interruptions throw a wrench in these schemes: depending on the exact timing of the
|
||||||
# interruption, we should or shouldn't expect some FINAL blocks.
|
# interruption, we should or shouldn't expect some FINAL blocks.
|
||||||
|
await asyncio.sleep(0.25)
|
||||||
self._assistant_is_responding = False
|
self._assistant_is_responding = False
|
||||||
await self._report_assistant_response_ended()
|
await self._report_assistant_response_ended()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user