Added better interruptability

This commit is contained in:
Chad Bailey
2024-02-22 14:45:38 -06:00
parent 85fe6c0580
commit 0244f358d2
3 changed files with 16 additions and 4 deletions

View File

@@ -147,13 +147,17 @@ class TTSService(AIService):
if text:
async for audio_chunk in self.run_tts(text):
yield AudioQueueFrame(audio_chunk)
print(f"audio chunk size: {len(audio_chunk)}")
size = 8000
for i in range(0, len(audio_chunk), size):
print(f"i is {i}")
yield AudioQueueFrame(audio_chunk[i : i+size])
yield TTSCompletedFrame(text)
async def finalize(self):
if self.current_sentence:
async for audio_chunk in self.run_tts(self.current_sentence):
yield AudioQueueFrame(audio_chunk)
yield AudioQueueFrame(audio_chunk)
# Convenience function to send the audio for a sentence to the given queue
async def say(self, sentence, queue: asyncio.Queue):

View File

@@ -158,8 +158,9 @@ class BaseTransportService():
break
# elif not isinstance(frame, TranscriptionQueueFrame):
# continue
if hasattr(frame, 'participantId') and frame.participantId == self._my_participant_id:
# TODO-CB: Verify this is an accurate replacement
# if hasattr(frame, 'participantId') and frame.participantId == self._my_participant_id:
if not isinstance(frame, UserStoppedSpeakingFrame):
continue
if current_response_task:

View File

@@ -0,0 +1,7 @@
import aiohttp
from dailyai.services.ai_services import LLMService
class GroqLLMService(LLMService):
def __init__(self, *, api_key, model="llama2-70b-4096"):
pass