feat: implement OpenAI-compatible Realtime API with authentication and management features
- Added support for public Realtime API, including new routes for managing API keys and handling WebRTC connections. - Introduced RealtimeApiKey model and associated CRUD operations for admin management of API keys. - Implemented authentication mechanisms for API keys and client secrets. - Enhanced environment configuration with new secrets for Realtime API. - Created OpenAIRealtime session management and event processing for real-time interactions. - Updated schemas and settings to accommodate new features and ensure compatibility with existing systems.
This commit is contained in:
@@ -25,6 +25,7 @@ from pipecat.transports.websocket.fastapi import (
|
||||
FastAPIWebsocketTransport,
|
||||
FastAPIWebsocketParams,
|
||||
)
|
||||
from pipecat.serializers.base_serializer import FrameSerializer
|
||||
from pipecat.serializers.protobuf import ProtobufFrameSerializer
|
||||
|
||||
from services.pipecat.call_lifecycle import FixedSpeechPlaybackMarkerFrame
|
||||
@@ -103,10 +104,33 @@ def build_ws_transport(websocket: WebSocket) -> FastAPIWebsocketTransport:
|
||||
"""裸 WS 输出。序列化用 protobuf(自定义客户端用同款解码);
|
||||
若对接电话商,把 serializer 换成对应的 TwilioFrameSerializer 等即可。
|
||||
"""
|
||||
return build_serialized_ws_transport(
|
||||
websocket,
|
||||
serializer=ProtobufFrameSerializer(),
|
||||
)
|
||||
|
||||
|
||||
def build_serialized_ws_transport(
|
||||
websocket: WebSocket,
|
||||
*,
|
||||
serializer: FrameSerializer,
|
||||
sample_rate: int | None = None,
|
||||
) -> FastAPIWebsocketTransport:
|
||||
"""Build a text/binary WS transport without coupling it to one protocol."""
|
||||
|
||||
sample_rates = (
|
||||
{
|
||||
"audio_in_sample_rate": sample_rate,
|
||||
"audio_out_sample_rate": sample_rate,
|
||||
}
|
||||
if sample_rate
|
||||
else {}
|
||||
)
|
||||
return _WebsocketTransport(
|
||||
websocket=websocket,
|
||||
params=FastAPIWebsocketParams(
|
||||
serializer=ProtobufFrameSerializer(),
|
||||
serializer=serializer,
|
||||
**_base_params(),
|
||||
**sample_rates,
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user