diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cdaea355..661921f30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## Added + +- `BaseOutputTransport` now implements `write_dtmf()` by loading DTMF audio and + sending it through the transport. This makes sending DTMF generic across all + output transports. + ## Changed - `pipecat.frames.frames.KeypadEntry` is deprecated and has been moved to diff --git a/src/pipecat/transports/base_output.py b/src/pipecat/transports/base_output.py index 432908151..53d61e486 100644 --- a/src/pipecat/transports/base_output.py +++ b/src/pipecat/transports/base_output.py @@ -19,6 +19,7 @@ from typing import Any, AsyncGenerator, Dict, List, Mapping, Optional from loguru import logger from PIL import Image +from pipecat.audio.dtmf.utils import load_dtmf_audio from pipecat.audio.mixers.base_audio_mixer import BaseAudioMixer from pipecat.audio.utils import create_stream_resampler, is_silence from pipecat.frames.frames import ( @@ -223,7 +224,12 @@ class BaseOutputTransport(FrameProcessor): Args: frame: The DTMF frame to write. """ - pass + dtmf_audio = await load_dtmf_audio(frame.button, sample_rate=self._sample_rate) + dtmf_audio_frame = OutputAudioRawFrame( + audio=dtmf_audio, sample_rate=self._sample_rate, num_channels=1 + ) + dtmf_audio_frame.transport_destination = frame.transport_destination + await self.write_audio_frame(dtmf_audio_frame) async def send_audio(self, frame: OutputAudioRawFrame): """Send an audio frame downstream.