Skip to content

Commit

Permalink
services(aws): don't block the asyncio event loop
Browse files Browse the repository at this point in the history
  • Loading branch information
aconchillo authored and markbackman committed Oct 2, 2024
1 parent 8aae4e9 commit f0e8bb7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/pipecat/services/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
# SPDX-License-Identifier: BSD 2-Clause License
#

import asyncio
from typing import AsyncGenerator, Optional

from loguru import logger
from pydantic import BaseModel

from pipecat.frames.frames import (
Expand All @@ -17,8 +19,6 @@
)
from pipecat.services.ai_services import TTSService

from loguru import logger

try:
import boto3
from botocore.exceptions import BotoCoreError, ClientError
Expand Down Expand Up @@ -146,7 +146,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
)

await self.start_tts_usage_metrics(text)

Expand Down

0 comments on commit f0e8bb7

Please sign in to comment.