Merge pull request #3991 from pipecat-ai/pk/fix-out-of-date-docstrings
Fix out of date docstrings
This commit is contained in:
1
changelog/3991.changed.md
Normal file
1
changelog/3991.changed.md
Normal file
@@ -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.
|
||||
@@ -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",
|
||||
)
|
||||
)
|
||||
"""
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
)
|
||||
)
|
||||
"""
|
||||
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user