minor cleanup

This commit is contained in:
Moishe Lettvin
2024-01-29 15:06:39 -05:00
parent d0bcddfd70
commit 4e9586595d
9 changed files with 40 additions and 49 deletions

View File

@@ -34,6 +34,7 @@ class LLMContextAggregator(AIService):
bot_participant_id=None,
complete_sentences=True,
pass_through=True):
super().__init__()
self.messages = messages
self.bot_participant_id = bot_participant_id
self.role = role
@@ -82,5 +83,5 @@ class LLMAssistantContextAggregator(LLMContextAggregator):
self, messages: list[dict], bot_participant_id=None, complete_sentences=True
):
super().__init__(
messages, "assistan", bot_participant_id, complete_sentences, pass_through=True
messages, "assistant", bot_participant_id, complete_sentences, pass_through=True
)

View File

@@ -391,10 +391,10 @@ class DailyTransportService(EventHandler):
all_audio_frames.extend(chunk)
b.extend(chunk)
l = len(b) - (len(b) % smallest_write_size)
if l:
self.mic.write_frames(bytes(b[:l]))
b = b[l:]
truncated_length: int = len(b) - (len(b) % smallest_write_size)
if truncated_length:
self.mic.write_frames(bytes(b[:truncated_length]))
b = b[truncated_length:]
elif isinstance(frame, ImageQueueFrame):
self._set_image(frame.image)
elif isinstance(frame, SpriteQueueFrame):
@@ -406,7 +406,8 @@ class DailyTransportService(EventHandler):
# if there are leftover audio bytes, write them now; failing to do so
# can cause static in the audio stream.
if len(b):
self.mic.write_frames(bytes(b))
truncated_length = len(b) - (len(b) % 160)
self.mic.write_frames(bytes(b[:truncated_length]))
b = bytearray()
if isinstance(frame, StartStreamQueueFrame):