Merge pull request #412 from pipecat-ai/aleix/fastapi-variable-clash
transports(fastapi): fix variable name clash
This commit is contained in:
@@ -5,6 +5,12 @@ All notable changes to **pipecat** will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix `FastAPIWebsocketOutputTransport` variable name clash with subclass.
|
||||||
|
|
||||||
## [0.0.40] - 2024-08-20
|
## [0.0.40] - 2024-08-20
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -91,13 +91,13 @@ class FastAPIWebsocketOutputTransport(BaseOutputTransport):
|
|||||||
|
|
||||||
self._websocket = websocket
|
self._websocket = websocket
|
||||||
self._params = params
|
self._params = params
|
||||||
self._audio_buffer = bytes()
|
self._websocket_audio_buffer = bytes()
|
||||||
|
|
||||||
async def write_raw_audio_frames(self, frames: bytes):
|
async def write_raw_audio_frames(self, frames: bytes):
|
||||||
self._audio_buffer += frames
|
self._websocket_audio_buffer += frames
|
||||||
while len(self._audio_buffer) >= self._params.audio_frame_size:
|
while len(self._websocket_audio_buffer) >= self._params.audio_frame_size:
|
||||||
frame = AudioRawFrame(
|
frame = AudioRawFrame(
|
||||||
audio=self._audio_buffer[:self._params.audio_frame_size],
|
audio=self._websocket_audio_buffer[:self._params.audio_frame_size],
|
||||||
sample_rate=self._params.audio_out_sample_rate,
|
sample_rate=self._params.audio_out_sample_rate,
|
||||||
num_channels=self._params.audio_out_channels
|
num_channels=self._params.audio_out_channels
|
||||||
)
|
)
|
||||||
@@ -121,7 +121,7 @@ class FastAPIWebsocketOutputTransport(BaseOutputTransport):
|
|||||||
if payload and self._websocket.client_state == WebSocketState.CONNECTED:
|
if payload and self._websocket.client_state == WebSocketState.CONNECTED:
|
||||||
await self._websocket.send_text(payload)
|
await self._websocket.send_text(payload)
|
||||||
|
|
||||||
self._audio_buffer = self._audio_buffer[self._params.audio_frame_size:]
|
self._websocket_audio_buffer = self._websocket_audio_buffer[self._params.audio_frame_size:]
|
||||||
|
|
||||||
|
|
||||||
class FastAPIWebsocketTransport(BaseTransport):
|
class FastAPIWebsocketTransport(BaseTransport):
|
||||||
|
|||||||
Reference in New Issue
Block a user