diff --git a/CHANGELOG.md b/CHANGELOG.md index e3b267519..661e0bb2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 the Telnyx call when an `EndFrame` or `CancelFrame` is received. It is enabled by default and is configurable via the `auto_hang_up` `InputParam`. +### Fixed + +- Fixed an issue where `TwilioFrameSerializer` would send two hang up commands: + one for the `EndFrame` and one for the `CancelFrame`. + ## [0.0.64] - 2025-04-22 ### Added diff --git a/src/pipecat/serializers/twilio.py b/src/pipecat/serializers/twilio.py index f1fc34c02..3c4c2a2c9 100644 --- a/src/pipecat/serializers/twilio.py +++ b/src/pipecat/serializers/twilio.py @@ -90,6 +90,7 @@ class TwilioFrameSerializer(FrameSerializer): self._sample_rate = 0 # Pipeline input rate self._resampler = create_default_resampler() + self._hangup_attempted = False @property def type(self) -> FrameSerializerType: @@ -120,7 +121,12 @@ class TwilioFrameSerializer(FrameSerializer): Returns: Serialized data as string or bytes, or None if the frame isn't handled. """ - if self._params.auto_hang_up and isinstance(frame, (EndFrame, CancelFrame)): + if ( + self._params.auto_hang_up + and not self._hangup_attempted + and isinstance(frame, (EndFrame, CancelFrame)) + ): + self._hangup_attempted = True await self._hang_up_call() return None elif isinstance(frame, StartInterruptionFrame):