chore: Review comments
This commit is contained in:
@@ -13,24 +13,39 @@ import aiohttp
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from pipecat.frames.frames import (AudioRawFrame, ErrorFrame, Frame,
|
from pipecat.frames.frames import (
|
||||||
LLMFullResponseEndFrame,
|
AudioRawFrame,
|
||||||
LLMFullResponseStartFrame, LLMMessagesFrame,
|
ErrorFrame,
|
||||||
LLMResponseEndFrame, LLMResponseStartFrame,
|
Frame,
|
||||||
TextFrame, URLImageRawFrame,
|
LLMFullResponseEndFrame,
|
||||||
VisionImageRawFrame)
|
LLMFullResponseStartFrame,
|
||||||
|
LLMMessagesFrame,
|
||||||
|
LLMResponseEndFrame,
|
||||||
|
LLMResponseStartFrame,
|
||||||
|
TextFrame,
|
||||||
|
URLImageRawFrame,
|
||||||
|
VisionImageRawFrame
|
||||||
|
)
|
||||||
from pipecat.processors.aggregators.openai_llm_context import (
|
from pipecat.processors.aggregators.openai_llm_context import (
|
||||||
OpenAILLMContext, OpenAILLMContextFrame)
|
OpenAILLMContext,
|
||||||
|
OpenAILLMContextFrame
|
||||||
|
)
|
||||||
from pipecat.processors.frame_processor import FrameDirection
|
from pipecat.processors.frame_processor import FrameDirection
|
||||||
from pipecat.services.ai_services import (ImageGenService, LLMService,
|
from pipecat.services.ai_services import (
|
||||||
TTSService)
|
ImageGenService,
|
||||||
|
LLMService,
|
||||||
|
TTSService
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from openai import AsyncOpenAI, AsyncStream, BadRequestError
|
from openai import AsyncOpenAI, AsyncStream, BadRequestError
|
||||||
from openai.types.chat import (ChatCompletion, ChatCompletionChunk,
|
from openai.types.chat import (
|
||||||
ChatCompletionFunctionMessageParam,
|
ChatCompletion,
|
||||||
ChatCompletionMessageParam,
|
ChatCompletionChunk,
|
||||||
ChatCompletionToolParam)
|
ChatCompletionFunctionMessageParam,
|
||||||
|
ChatCompletionMessageParam,
|
||||||
|
ChatCompletionToolParam
|
||||||
|
)
|
||||||
except ModuleNotFoundError as e:
|
except ModuleNotFoundError as e:
|
||||||
logger.error(f"Exception: {e}")
|
logger.error(f"Exception: {e}")
|
||||||
logger.error(
|
logger.error(
|
||||||
@@ -265,7 +280,7 @@ class OpenAIImageGenService(ImageGenService):
|
|||||||
|
|
||||||
class OpenAITTSService(TTSService):
|
class OpenAITTSService(TTSService):
|
||||||
"""This service uses the OpenAI TTS API to generate audio from text.
|
"""This service uses the OpenAI TTS API to generate audio from text.
|
||||||
The returned audio is PCM encoded at 24kHz. When using the DailyTransport, set the sample rate in the DailyParams:
|
The returned audio is PCM encoded at 24kHz. When using the DailyTransport, set the sample rate in the DailyParams accordingly:
|
||||||
```
|
```
|
||||||
DailyParams(
|
DailyParams(
|
||||||
audio_out_enabled=True,
|
audio_out_enabled=True,
|
||||||
@@ -308,5 +323,4 @@ class OpenAITTSService(TTSService):
|
|||||||
frame = AudioRawFrame(chunk, 24_000, 1)
|
frame = AudioRawFrame(chunk, 24_000, 1)
|
||||||
yield frame
|
yield frame
|
||||||
except BadRequestError as e:
|
except BadRequestError as e:
|
||||||
logger.exception(f"Error generating TTS: {e}")
|
logger.error(f"Error generating TTS: {e}")
|
||||||
raise
|
|
||||||
|
|||||||
Reference in New Issue
Block a user