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::
|
Example::
|
||||||
|
|
||||||
# Basic usage with mars-flash (fast)
|
# 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
|
# High quality with mars-pro
|
||||||
tts = CambTTSService(
|
tts = CambTTSService(
|
||||||
api_key="your-api-key",
|
api_key="your-api-key",
|
||||||
voice_id=12345,
|
settings=CambTTSService.Settings(
|
||||||
model="mars-pro",
|
voice=12345,
|
||||||
|
model="mars-pro",
|
||||||
|
)
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class DeepgramSageMakerSTTService(STTService):
|
|||||||
stt = DeepgramSageMakerSTTService(
|
stt = DeepgramSageMakerSTTService(
|
||||||
endpoint_name="my-deepgram-endpoint",
|
endpoint_name="my-deepgram-endpoint",
|
||||||
region="us-east-2",
|
region="us-east-2",
|
||||||
settings=DeepgramSageMakerSTTSettings(
|
settings=DeepgramSageMakerSTTService.Settings(
|
||||||
model="nova-3",
|
model="nova-3",
|
||||||
language="en",
|
language="en",
|
||||||
interim_results=True,
|
interim_results=True,
|
||||||
|
|||||||
@@ -63,7 +63,9 @@ class DeepgramSageMakerTTSService(TTSService):
|
|||||||
tts = DeepgramSageMakerTTSService(
|
tts = DeepgramSageMakerTTSService(
|
||||||
endpoint_name="my-deepgram-tts-endpoint",
|
endpoint_name="my-deepgram-tts-endpoint",
|
||||||
region="us-east-2",
|
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(
|
tts = GoogleTTSService(
|
||||||
credentials_path="/path/to/service-account.json",
|
credentials_path="/path/to/service-account.json",
|
||||||
voice_id="en-US-Chirp3-HD-Charon",
|
settings=GoogleTTSService.Settings(
|
||||||
params=GoogleTTSService.InputParams(
|
voice="en-US-Chirp3-HD-Charon",
|
||||||
language=Language.EN_US,
|
language=Language.EN_US,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -1191,9 +1191,9 @@ class GeminiTTSService(GoogleBaseTTSService):
|
|||||||
|
|
||||||
tts = GeminiTTSService(
|
tts = GeminiTTSService(
|
||||||
credentials_path="/path/to/service-account.json",
|
credentials_path="/path/to/service-account.json",
|
||||||
model="gemini-2.5-flash-tts",
|
settings=GeminiTTSService.Settings(
|
||||||
voice_id="Kore",
|
model="gemini-2.5-flash-tts",
|
||||||
params=GeminiTTSService.InputParams(
|
voice="Kore",
|
||||||
language=Language.EN_US,
|
language=Language.EN_US,
|
||||||
prompt="Say this in a friendly and helpful tone"
|
prompt="Say this in a friendly and helpful tone"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -187,9 +187,15 @@ class OpenAIRealtimeSTTSettings(STTSettings):
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
prompt: Optional prompt text to guide transcription style.
|
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)
|
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):
|
class OpenAIRealtimeSTTService(WebsocketSTTService):
|
||||||
@@ -220,8 +226,10 @@ class OpenAIRealtimeSTTService(WebsocketSTTService):
|
|||||||
|
|
||||||
stt = OpenAIRealtimeSTTService(
|
stt = OpenAIRealtimeSTTService(
|
||||||
api_key="sk-...",
|
api_key="sk-...",
|
||||||
model="gpt-4o-transcribe",
|
settings=OpenAIRealtimeSTTService.Settings(
|
||||||
noise_reduction="near_field",
|
model="gpt-4o-transcribe",
|
||||||
|
noise_reduction="near_field",
|
||||||
|
),
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -274,6 +282,9 @@ class OpenAIRealtimeSTTService(WebsocketSTTService):
|
|||||||
noise_reduction: Noise reduction mode. ``"near_field"`` for
|
noise_reduction: Noise reduction mode. ``"near_field"`` for
|
||||||
close microphones, ``"far_field"`` for distant
|
close microphones, ``"far_field"`` for distant
|
||||||
microphones, or ``None`` to disable.
|
microphones, or ``None`` to disable.
|
||||||
|
|
||||||
|
.. deprecated:: 0.0.106
|
||||||
|
Use ``settings=OpenAIRealtimeSTTSettings(noise_reduction=...)`` instead.
|
||||||
should_interrupt: Whether to interrupt bot output when
|
should_interrupt: Whether to interrupt bot output when
|
||||||
speech is detected by server-side VAD. Only applies when
|
speech is detected by server-side VAD. Only applies when
|
||||||
turn detection is enabled. Defaults to True.
|
turn detection is enabled. Defaults to True.
|
||||||
@@ -295,6 +306,7 @@ class OpenAIRealtimeSTTService(WebsocketSTTService):
|
|||||||
model="gpt-4o-transcribe",
|
model="gpt-4o-transcribe",
|
||||||
language=Language.EN,
|
language=Language.EN,
|
||||||
prompt=None,
|
prompt=None,
|
||||||
|
noise_reduction=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
# --- 2. Deprecated direct-arg overrides ---
|
# --- 2. Deprecated direct-arg overrides ---
|
||||||
@@ -307,6 +319,9 @@ class OpenAIRealtimeSTTService(WebsocketSTTService):
|
|||||||
if prompt is not None:
|
if prompt is not None:
|
||||||
_warn_deprecated_param("prompt", OpenAIRealtimeSTTSettings, "prompt")
|
_warn_deprecated_param("prompt", OpenAIRealtimeSTTSettings, "prompt")
|
||||||
default_settings.prompt = 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) ---
|
# --- 3. (no params object for this service) ---
|
||||||
|
|
||||||
@@ -324,7 +339,6 @@ class OpenAIRealtimeSTTService(WebsocketSTTService):
|
|||||||
self._base_url = base_url
|
self._base_url = base_url
|
||||||
|
|
||||||
self._turn_detection = turn_detection
|
self._turn_detection = turn_detection
|
||||||
self._noise_reduction = noise_reduction
|
|
||||||
self._should_interrupt = should_interrupt
|
self._should_interrupt = should_interrupt
|
||||||
|
|
||||||
self._receive_task = None
|
self._receive_task = None
|
||||||
@@ -544,9 +558,9 @@ class OpenAIRealtimeSTTService(WebsocketSTTService):
|
|||||||
input_audio["turn_detection"] = self._turn_detection
|
input_audio["turn_detection"] = self._turn_detection
|
||||||
|
|
||||||
# Noise reduction
|
# Noise reduction
|
||||||
if self._noise_reduction:
|
if self._settings.noise_reduction:
|
||||||
input_audio["noise_reduction"] = {
|
input_audio["noise_reduction"] = {
|
||||||
"type": self._noise_reduction,
|
"type": self._settings.noise_reduction,
|
||||||
}
|
}
|
||||||
|
|
||||||
await self._ws_send(
|
await self._ws_send(
|
||||||
|
|||||||
@@ -326,28 +326,28 @@ class SarvamHttpTTSService(TTSService):
|
|||||||
# Using bulbul:v2 (default)
|
# Using bulbul:v2 (default)
|
||||||
tts = SarvamHttpTTSService(
|
tts = SarvamHttpTTSService(
|
||||||
api_key="your-api-key",
|
api_key="your-api-key",
|
||||||
voice_id="anushka",
|
|
||||||
model="bulbul:v2",
|
|
||||||
aiohttp_session=session,
|
aiohttp_session=session,
|
||||||
params=SarvamHttpTTSService.InputParams(
|
settings=SarvamHttpTTSService.Settings(
|
||||||
|
voice="anushka",
|
||||||
|
model="bulbul:v2",
|
||||||
language=Language.HI,
|
language=Language.HI,
|
||||||
pitch=0.1,
|
pitch=0.1,
|
||||||
pace=1.2,
|
pace=1.2,
|
||||||
loudness=1.5
|
loudness=1.5,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Using bulbul:v3-beta with temperature control
|
# Using bulbul:v3-beta with temperature control
|
||||||
tts_v3 = SarvamHttpTTSService(
|
tts_v3 = SarvamHttpTTSService(
|
||||||
api_key="your-api-key",
|
api_key="your-api-key",
|
||||||
voice_id="aditya", # Use v3 speaker
|
|
||||||
model="bulbul:v3-beta",
|
|
||||||
aiohttp_session=session,
|
aiohttp_session=session,
|
||||||
params=SarvamHttpTTSService.InputParams(
|
settings=SarvamHttpTTSService.Settings(
|
||||||
|
voice="aditya", # Use v3 speaker
|
||||||
|
model="bulbul:v3-beta",
|
||||||
language=Language.HI,
|
language=Language.HI,
|
||||||
pace=1.2, # Range: 0.5-2.0 for v3
|
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)
|
# Using bulbul:v2 (default)
|
||||||
tts = SarvamTTSService(
|
tts = SarvamTTSService(
|
||||||
api_key="your-api-key",
|
api_key="your-api-key",
|
||||||
voice_id="anushka",
|
settings=SarvamTTSService.Settings(
|
||||||
model="bulbul:v2",
|
voice="anushka",
|
||||||
params=SarvamTTSService.InputParams(
|
model="bulbul:v2",
|
||||||
language=Language.HI,
|
language=Language.HI,
|
||||||
pitch=0.1,
|
pitch=0.1,
|
||||||
pace=1.2,
|
pace=1.2,
|
||||||
loudness=1.5
|
loudness=1.5,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Using bulbul:v3-beta with temperature control
|
# Using bulbul:v3-beta with temperature control
|
||||||
tts_v3 = SarvamTTSService(
|
tts_v3 = SarvamTTSService(
|
||||||
api_key="your-api-key",
|
api_key="your-api-key",
|
||||||
voice_id="aditya", # Use v3 speaker
|
settings=SarvamTTSService.Settings(
|
||||||
model="bulbul:v3-beta",
|
voice="aditya", # Use v3 speaker
|
||||||
params=SarvamTTSService.InputParams(
|
model="bulbul:v3-beta",
|
||||||
language=Language.HI,
|
language=Language.HI,
|
||||||
pace=1.2, # Range: 0.5-2.0 for v3
|
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.
|
See https://docs.sarvam.ai/api-reference-docs/text-to-speech/stream for API details.
|
||||||
|
|||||||
Reference in New Issue
Block a user