BaseOutputTransport: implement generic write_dtmf()
This commit is contained in:
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [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
|
## Changed
|
||||||
|
|
||||||
- `pipecat.frames.frames.KeypadEntry` is deprecated and has been moved to
|
- `pipecat.frames.frames.KeypadEntry` is deprecated and has been moved to
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from typing import Any, AsyncGenerator, Dict, List, Mapping, Optional
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
from PIL import Image
|
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.mixers.base_audio_mixer import BaseAudioMixer
|
||||||
from pipecat.audio.utils import create_stream_resampler, is_silence
|
from pipecat.audio.utils import create_stream_resampler, is_silence
|
||||||
from pipecat.frames.frames import (
|
from pipecat.frames.frames import (
|
||||||
@@ -223,7 +224,12 @@ class BaseOutputTransport(FrameProcessor):
|
|||||||
Args:
|
Args:
|
||||||
frame: The DTMF frame to write.
|
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):
|
async def send_audio(self, frame: OutputAudioRawFrame):
|
||||||
"""Send an audio frame downstream.
|
"""Send an audio frame downstream.
|
||||||
|
|||||||
Reference in New Issue
Block a user