diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a44d17a0..362116d5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Added `MCPClient`; a way to connect to MCP servers and use the MCP servers' tools. +- Added `TransportParams.audio_in_passthrough`. If set (the default), incoming + audio will be pushed downstream. + +- Added `MCPClient`; a way to connect to MCP servers and use the MCP servers' + tools. + +### Changed + +- Input transports now always push audio downstream unless disabled with + `TransportParams.audio_in_passthrough`. After many Pipecat releases, we + realized this is the common use case. There are use cases where the input + transport already provides STT and you also don't want recordings, in which + case there's no need to push audio to the rest of the pipeline, but this is + not a very common case. + +### Deprecated + +- `TransportParams.vad_audio_passthrough` parameter is now deprecated, use + `TransportParams.audio_in_passthrough` instead. ### Fixed diff --git a/src/pipecat/transports/base_input.py b/src/pipecat/transports/base_input.py index 3e3760be1..0f206f08e 100644 --- a/src/pipecat/transports/base_input.py +++ b/src/pipecat/transports/base_input.py @@ -6,7 +6,7 @@ import asyncio from concurrent.futures import ThreadPoolExecutor -from typing import Mapping, Optional +from typing import Optional from loguru import logger @@ -33,7 +33,7 @@ from pipecat.frames.frames import ( UserStoppedSpeakingFrame, VADParamsUpdateFrame, ) -from pipecat.metrics.metrics import MetricsData, SmartTurnMetricsData +from pipecat.metrics.metrics import MetricsData from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.transports.base_transport import TransportParams @@ -55,6 +55,17 @@ class BaseInputTransport(FrameProcessor): # if passthrough is enabled. self._audio_task = None + if self._params.vad_audio_passthrough: + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "Parameter 'vad_audio_passthrough' is deprecated, audio passthrough is now always enabled. Use 'audio_in_passthrough' to disable.", + DeprecationWarning, + ) + self._params.audio_in_passthrough = True + def enable_audio_in_stream_on_start(self, enabled: bool) -> None: logger.debug(f"Enabling audio on start. {enabled}") self._params.audio_in_stream_on_start = enabled @@ -247,8 +258,6 @@ class BaseInputTransport(FrameProcessor): while True: frame: InputAudioRawFrame = await self._audio_in_queue.get() - audio_passthrough = True - # If an audio filter is available, run it before VAD. if self._params.audio_in_filter: frame.audio = await self._params.audio_in_filter.filter(frame.audio) @@ -258,13 +267,12 @@ class BaseInputTransport(FrameProcessor): previous_vad_state = vad_state if self._params.vad_enabled: vad_state = await self._handle_vad(frame, vad_state) - audio_passthrough = self._params.vad_audio_passthrough if self._params.turn_analyzer: await self._run_turn_analyzer(frame, vad_state, previous_vad_state) - # Push audio downstream if passthrough. - if audio_passthrough: + # Push audio downstream if passthrough is set. + if self._params.audio_in_passthrough: await self.push_frame(frame) self._audio_in_queue.task_done() diff --git a/src/pipecat/transports/base_transport.py b/src/pipecat/transports/base_transport.py index 9ef573f7c..28bbfe055 100644 --- a/src/pipecat/transports/base_transport.py +++ b/src/pipecat/transports/base_transport.py @@ -39,6 +39,7 @@ class TransportParams(BaseModel): audio_in_channels: int = 1 audio_in_filter: Optional[BaseAudioFilter] = None audio_in_stream_on_start: bool = True + audio_in_passthrough: bool = True vad_enabled: bool = False vad_audio_passthrough: bool = False vad_analyzer: Optional[VADAnalyzer] = None