From e37f2f99c473350de24f2ec3e52f98132fbc2c19 Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Fri, 13 Feb 2026 11:39:34 -0500 Subject: [PATCH] Deprecate `set_model`, `set_voice`, and `set_language` in favor of `*UpdateSettingsFrame`. --- src/pipecat/services/stt_service.py | 25 +++++++++++++++++++------ src/pipecat/services/tts_service.py | 29 +++++++++++++++++++---------- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/src/pipecat/services/stt_service.py b/src/pipecat/services/stt_service.py index 22cd4f03d..3ce143d92 100644 --- a/src/pipecat/services/stt_service.py +++ b/src/pipecat/services/stt_service.py @@ -9,6 +9,7 @@ import asyncio import io import time +import warnings import wave from abc import abstractmethod from typing import Any, AsyncGenerator, Dict, Mapping, Optional @@ -168,13 +169,19 @@ class STTService(AIService): async def set_model(self, model: str): """Set the speech recognition model. - When the service has been migrated to typed settings this routes - through :meth:`_update_settings_from_typed` so that concrete - services can react (e.g. reconnect) in a single place. + .. deprecated:: 0.0.103 + Use ``STTUpdateSettingsFrame(model=...)`` instead. Args: model: The name of the model to use for speech recognition. """ + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "'set_model' is deprecated, use 'STTUpdateSettingsFrame(model=...)' instead.", + DeprecationWarning, + stacklevel=2, + ) logger.info(f"Switching STT model to: [{model}]") if isinstance(self._settings, ServiceSettings): settings_cls = type(self._settings) @@ -185,13 +192,19 @@ class STTService(AIService): async def set_language(self, language: Language): """Set the language for speech recognition. - When the service has been migrated to typed settings this routes - through :meth:`_update_settings_from_typed` so that concrete - services can react (e.g. reconnect) in a single place. + .. deprecated:: 0.0.103 + Use ``STTUpdateSettingsFrame(language=...)`` instead. Args: language: The language to use for speech recognition. """ + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "'set_language' is deprecated, use 'STTUpdateSettingsFrame(language=...)' instead.", + DeprecationWarning, + stacklevel=2, + ) logger.info(f"Switching STT language to: [{language}]") if isinstance(self._settings, ServiceSettings): settings_cls = type(self._settings) diff --git a/src/pipecat/services/tts_service.py b/src/pipecat/services/tts_service.py index 49bb29970..b16ebdb24 100644 --- a/src/pipecat/services/tts_service.py +++ b/src/pipecat/services/tts_service.py @@ -8,6 +8,7 @@ import asyncio import uuid +import warnings from abc import abstractmethod from dataclasses import dataclass from typing import ( @@ -265,13 +266,19 @@ class TTSService(AIService): async def set_model(self, model: str): """Set the TTS model to use. - When the service has been migrated to typed settings this routes - through :meth:`_update_settings_from_typed` so that concrete - services can react (e.g. reconnect) in a single place. + .. deprecated:: 0.0.103 + Use ``TTSUpdateSettingsFrame(model=...)`` instead. Args: model: The name of the TTS model. """ + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "'set_model' is deprecated, use 'TTSUpdateSettingsFrame(model=...)' instead.", + DeprecationWarning, + stacklevel=2, + ) logger.info(f"Switching TTS model to: [{model}]") if isinstance(self._settings, ServiceSettings): settings_cls = type(self._settings) @@ -282,17 +289,19 @@ class TTSService(AIService): async def set_voice(self, voice: str): """Set the voice for speech synthesis. - When the service has been migrated to typed settings this routes - through :meth:`_update_settings_from_typed` so that concrete - services can react (e.g. reconnect) in a single place. - - .. versionchanged:: 0.0.103 - Now ``async``. In ``__init__`` methods, set - ``self._voice_id`` directly instead of calling this method. + .. deprecated:: 0.0.103 + Use ``TTSUpdateSettingsFrame(voice=...)`` instead. Args: voice: The voice identifier or name. """ + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "'set_voice' is deprecated, use 'TTSUpdateSettingsFrame(voice=...)' instead.", + DeprecationWarning, + stacklevel=2, + ) logger.info(f"Switching TTS voice to: [{voice}]") if isinstance(self._settings, ServiceSettings): settings_cls = type(self._settings)