Merge pull request #2435 from pipecat-ai/filipi/small_webrtc_end_pipeline

Fixed an issue where `SmallWebRTCTransport` ended before TTS finished.
This commit is contained in:
Filipi da Silva Fuchter
2025-08-13 11:58:33 -03:00
committed by GitHub
2 changed files with 8 additions and 0 deletions

View File

@@ -64,6 +64,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fixed an issue where `SmallWebRTCTransport` ended before TTS finished.
- Fixed a `WatchdogPriorityQueue` issue that could cause an exception when
compating watchdog cancel sentinel items with other items in the queue.

View File

@@ -226,6 +226,7 @@ class SmallWebRTCClient:
self._audio_in_channels = None
self._in_sample_rate = None
self._out_sample_rate = None
self._leave_counter = 0
# We are always resampling it for 16000 if the sample_rate that we receive is bigger than that.
# otherwise we face issues with Silero VAD
@@ -395,6 +396,7 @@ class SmallWebRTCClient:
self._in_sample_rate = _params.audio_in_sample_rate or frame.audio_in_sample_rate
self._out_sample_rate = _params.audio_out_sample_rate or frame.audio_out_sample_rate
self._params = _params
self._leave_counter += 1
async def connect(self):
"""Establish the WebRTC connection."""
@@ -407,6 +409,10 @@ class SmallWebRTCClient:
async def disconnect(self):
"""Disconnect from the WebRTC peer."""
self._leave_counter -= 1
if self._leave_counter > 0:
return
if self.is_connected and not self.is_closing:
logger.info(f"Disconnecting to Small WebRTC")
self._closing = True