-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add calls to flush_audio for say() and rtvi action #492
Conversation
src/pipecat/services/ai_services.py
Outdated
@@ -186,6 +186,7 @@ async def run_tts(self, text: str) -> AsyncGenerator[Frame, None]: | |||
|
|||
async def say(self, text: str): | |||
await self.process_frame(TextFrame(text=text), FrameDirection.DOWNSTREAM) | |||
await self.flush_audio() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flush_audio
is only available in AsynTTSService
since I thought it only made sense there. We have two options:
- Add
flush_audio
toTTSService
- Override
say()
inAsyncTTSService
with
async def say(self, text: str):
super().say(text)
await self.flush_audio()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's anything to flush in TTSService
, so maybe option 2 is better?
src/pipecat/services/ai_services.py
Outdated
@@ -235,6 +236,7 @@ async def process_frame(self, frame: Frame, direction: FrameDirection): | |||
await self.push_frame(frame, direction) | |||
elif isinstance(frame, TTSSpeakFrame): | |||
await self._push_tts_frames(frame.text) | |||
await self.flush_audio() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
async def process_frame(self, frame: Frame, direction: FrameDirection):
super().process_frame(frame, direction)
if isinstance(frame, TTSSpeakFrame):
await self.flush_audio()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be await super().process_frame(frame, direction)
, right?
(An await
in front of the call to the super class's method.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorry.
cb11b6f
to
3621fce
Compare
src/pipecat/services/ai_services.py
Outdated
@@ -278,6 +282,11 @@ async def cancel(self, frame: CancelFrame): | |||
await self._stop_frame_task | |||
self._stop_frame_task = None | |||
|
|||
async def process_frame(self, frame: Frame, direction: FrameDirection): | |||
super().process_frame(frame, direction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are still missing the await
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Egads. Sorry. I clearly do not know how to use computers.
LGTM! |
Call
flush_audio()
after direct calls to TTSsay()
and when processingTTSSpeakFrame
s.