frame and pipeline docstrings

This commit is contained in:
Moishe Lettvin
2024-03-06 12:52:44 -05:00
parent eb430621f1
commit 337ca7f581
3 changed files with 59 additions and 23 deletions

View File

@@ -59,9 +59,6 @@ class AIService(FrameProcessor):
break
else:
raise Exception("Frames must be an iterable or async iterable")
async for output_frame in self.finalize():
yield output_frame
except Exception as e:
self.logger.error("Exception occurred while running AI service", e)
raise e
@@ -103,6 +100,7 @@ class TTSService(AIService):
# yield empty bytes here, so linting can infer what this method does
yield bytes()
<<<<<<< HEAD
async def process_frame(self, frame: Frame) -> AsyncGenerator[Frame, None]:
if isinstance(frame, EndFrame):
if self.current_sentence:
@@ -111,6 +109,14 @@ class TTSService(AIService):
yield frame
if not isinstance(frame, TextFrame):
=======
async def process_frame(self, frame: QueueFrame) -> AsyncGenerator[QueueFrame, None]:
if not isinstance(frame, TextQueueFrame):
if self.current_sentence:
async for audio_chunk in self.run_tts(self.current_sentence):
yield AudioQueueFrame(audio_chunk)
>>>>>>> fa5f38c (frame and pipeline docstrings)
yield frame
return
@@ -127,9 +133,12 @@ class TTSService(AIService):
async for audio_chunk in self.run_tts(text):
yield AudioFrame(audio_chunk)
<<<<<<< HEAD
# note we pass along the text frame *after* the audio, so the text frame is completed after the audio is processed.
yield TextFrame(text)
=======
>>>>>>> fa5f38c (frame and pipeline docstrings)
# Convenience function to send the audio for a sentence to the given queue
async def say(self, sentence, queue: asyncio.Queue):
await self.run_to_queue(queue, [TextFrame(sentence)])