diff --git a/changelog/3991.changed.md b/changelog/3991.changed.md new file mode 100644 index 000000000..5767dc8aa --- /dev/null +++ b/changelog/3991.changed.md @@ -0,0 +1 @@ +- `OpenAIRealtimeSTTService`'s `noise_reduction` parameter is now part of `OpenAIRealtimeSTTSettings`, making it runtime-updatable via `STTUpdateSettingsFrame`. The direct `noise_reduction` init argument is deprecated as of 0.0.106. diff --git a/src/pipecat/services/camb/tts.py b/src/pipecat/services/camb/tts.py index 9918b2320..f458fa2e4 100644 --- a/src/pipecat/services/camb/tts.py +++ b/src/pipecat/services/camb/tts.py @@ -158,13 +158,20 @@ class CambTTSService(TTSService): Example:: # Basic usage with mars-flash (fast) - tts = CambTTSService(api_key="your-api-key", model="mars-flash") + tts = CambTTSService( + api_key="your-api-key", + settings=CambTTSService.Settings( + model="mars-flash" + ) + ) # High quality with mars-pro tts = CambTTSService( api_key="your-api-key", - voice_id=12345, - model="mars-pro", + settings=CambTTSService.Settings( + voice=12345, + model="mars-pro", + ) ) """ diff --git a/src/pipecat/services/deepgram/sagemaker/stt.py b/src/pipecat/services/deepgram/sagemaker/stt.py index 812a2701e..f6093a630 100644 --- a/src/pipecat/services/deepgram/sagemaker/stt.py +++ b/src/pipecat/services/deepgram/sagemaker/stt.py @@ -69,7 +69,7 @@ class DeepgramSageMakerSTTService(STTService): stt = DeepgramSageMakerSTTService( endpoint_name="my-deepgram-endpoint", region="us-east-2", - settings=DeepgramSageMakerSTTSettings( + settings=DeepgramSageMakerSTTService.Settings( model="nova-3", language="en", interim_results=True, diff --git a/src/pipecat/services/deepgram/sagemaker/tts.py b/src/pipecat/services/deepgram/sagemaker/tts.py index a40f56713..d315b9e01 100644 --- a/src/pipecat/services/deepgram/sagemaker/tts.py +++ b/src/pipecat/services/deepgram/sagemaker/tts.py @@ -63,7 +63,9 @@ class DeepgramSageMakerTTSService(TTSService): tts = DeepgramSageMakerTTSService( endpoint_name="my-deepgram-tts-endpoint", region="us-east-2", - voice="aura-2-helena-en", + settings=DeepgramSageMakerTTSService.Settings( + voice="aura-2-helena-en", + ) ) """ diff --git a/src/pipecat/services/google/tts.py b/src/pipecat/services/google/tts.py index a9394028b..9d92c91ea 100644 --- a/src/pipecat/services/google/tts.py +++ b/src/pipecat/services/google/tts.py @@ -1014,8 +1014,8 @@ class GoogleTTSService(GoogleBaseTTSService): tts = GoogleTTSService( credentials_path="/path/to/service-account.json", - voice_id="en-US-Chirp3-HD-Charon", - params=GoogleTTSService.InputParams( + settings=GoogleTTSService.Settings( + voice="en-US-Chirp3-HD-Charon", language=Language.EN_US, ) ) @@ -1191,9 +1191,9 @@ class GeminiTTSService(GoogleBaseTTSService): tts = GeminiTTSService( credentials_path="/path/to/service-account.json", - model="gemini-2.5-flash-tts", - voice_id="Kore", - params=GeminiTTSService.InputParams( + settings=GeminiTTSService.Settings( + model="gemini-2.5-flash-tts", + voice="Kore", language=Language.EN_US, prompt="Say this in a friendly and helpful tone" ) diff --git a/src/pipecat/services/openai/stt.py b/src/pipecat/services/openai/stt.py index e2f9ec0ee..473b23637 100644 --- a/src/pipecat/services/openai/stt.py +++ b/src/pipecat/services/openai/stt.py @@ -187,9 +187,15 @@ class OpenAIRealtimeSTTSettings(STTSettings): Parameters: prompt: Optional prompt text to guide transcription style. + noise_reduction: Noise reduction mode. ``"near_field"`` for close + microphones, ``"far_field"`` for distant microphones, or ``None`` + to disable. """ prompt: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + noise_reduction: Literal["near_field", "far_field"] | None | _NotGiven = field( + default_factory=lambda: NOT_GIVEN + ) class OpenAIRealtimeSTTService(WebsocketSTTService): @@ -220,8 +226,10 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): stt = OpenAIRealtimeSTTService( api_key="sk-...", - model="gpt-4o-transcribe", - noise_reduction="near_field", + settings=OpenAIRealtimeSTTService.Settings( + model="gpt-4o-transcribe", + noise_reduction="near_field", + ), ) """ @@ -274,6 +282,9 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): noise_reduction: Noise reduction mode. ``"near_field"`` for close microphones, ``"far_field"`` for distant microphones, or ``None`` to disable. + + .. deprecated:: 0.0.106 + Use ``settings=OpenAIRealtimeSTTSettings(noise_reduction=...)`` instead. should_interrupt: Whether to interrupt bot output when speech is detected by server-side VAD. Only applies when turn detection is enabled. Defaults to True. @@ -295,6 +306,7 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): model="gpt-4o-transcribe", language=Language.EN, prompt=None, + noise_reduction=None, ) # --- 2. Deprecated direct-arg overrides --- @@ -307,6 +319,9 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): if prompt is not None: _warn_deprecated_param("prompt", OpenAIRealtimeSTTSettings, "prompt") default_settings.prompt = prompt + if noise_reduction is not None: + _warn_deprecated_param("noise_reduction", OpenAIRealtimeSTTSettings, "noise_reduction") + default_settings.noise_reduction = noise_reduction # --- 3. (no params object for this service) --- @@ -324,7 +339,6 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): self._base_url = base_url self._turn_detection = turn_detection - self._noise_reduction = noise_reduction self._should_interrupt = should_interrupt self._receive_task = None @@ -544,9 +558,9 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): input_audio["turn_detection"] = self._turn_detection # Noise reduction - if self._noise_reduction: + if self._settings.noise_reduction: input_audio["noise_reduction"] = { - "type": self._noise_reduction, + "type": self._settings.noise_reduction, } await self._ws_send( diff --git a/src/pipecat/services/sarvam/tts.py b/src/pipecat/services/sarvam/tts.py index 639a860ac..0d6a872eb 100644 --- a/src/pipecat/services/sarvam/tts.py +++ b/src/pipecat/services/sarvam/tts.py @@ -326,28 +326,28 @@ class SarvamHttpTTSService(TTSService): # Using bulbul:v2 (default) tts = SarvamHttpTTSService( api_key="your-api-key", - voice_id="anushka", - model="bulbul:v2", aiohttp_session=session, - params=SarvamHttpTTSService.InputParams( + settings=SarvamHttpTTSService.Settings( + voice="anushka", + model="bulbul:v2", language=Language.HI, pitch=0.1, pace=1.2, - loudness=1.5 - ) + loudness=1.5, + ), ) # Using bulbul:v3-beta with temperature control tts_v3 = SarvamHttpTTSService( api_key="your-api-key", - voice_id="aditya", # Use v3 speaker - model="bulbul:v3-beta", aiohttp_session=session, - params=SarvamHttpTTSService.InputParams( + settings=SarvamHttpTTSService.Settings( + voice="aditya", # Use v3 speaker + model="bulbul:v3-beta", language=Language.HI, pace=1.2, # Range: 0.5-2.0 for v3 - temperature=0.8 - ) + temperature=0.8, + ), ) """ @@ -693,26 +693,26 @@ class SarvamTTSService(InterruptibleTTSService): # Using bulbul:v2 (default) tts = SarvamTTSService( api_key="your-api-key", - voice_id="anushka", - model="bulbul:v2", - params=SarvamTTSService.InputParams( + settings=SarvamTTSService.Settings( + voice="anushka", + model="bulbul:v2", language=Language.HI, pitch=0.1, pace=1.2, - loudness=1.5 - ) + loudness=1.5, + ), ) # Using bulbul:v3-beta with temperature control tts_v3 = SarvamTTSService( api_key="your-api-key", - voice_id="aditya", # Use v3 speaker - model="bulbul:v3-beta", - params=SarvamTTSService.InputParams( + settings=SarvamTTSService.Settings( + voice="aditya", # Use v3 speaker + model="bulbul:v3-beta", language=Language.HI, pace=1.2, # Range: 0.5-2.0 for v3 - temperature=0.8 - ) + temperature=0.8, + ), ) See https://docs.sarvam.ai/api-reference-docs/text-to-speech/stream for API details.