-
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
services(aws): don't block the asyncio event loop #535
Conversation
src/pipecat/services/aws.py
Outdated
@@ -146,7 +148,9 @@ async def run_tts(self, text: str) -> AsyncGenerator[Frame, None]: | |||
# Filter out None values | |||
filtered_params = {k: v for k, v in params.items() if v is not None} | |||
|
|||
response = self._polly_client.synthesize_speech(**filtered_params) | |||
response = await asyncio.to_thread( | |||
self._polly_client.synthesize_speech(**filtered_params) |
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 think this needs this update otherwise it's treated as callable.
self._polly_client.synthesize_speech(**filtered_params) | |
lambda: self._polly_client.synthesize_speech(**filtered_params) |
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.
Oops, sorry. It has to be (updated):
response = await asyncio.to_thread(
self._polly_client.synthesize_speech, **filtered_params
)
This does work to generate speech sooner, but it produces choppy audio until all of the speech is generated. Once the speech is generated, then things smooth out. I think this has to do with a limitation with Polly where it's intended to generate speech entirely before responding. You can test this out with |
Yes, but it would be the same without the asyncio.thread right? |
The asyncio.thread only prevents the asyncio event loop not being blocked. It doesn't fix anything else. |
10dc293
to
c4ba426
Compare
c4ba426
to
f0e8bb7
Compare
I just pushed the change you suggested above. Using it, I still get choppy speech when a lot of text is generated. We need to better understand the root cause before merging this. |
f0e8bb7
to
e1075e2
Compare
So weird, let's close for now. |
No description provided.