Add class-level _settings type annotations to all service classes for better editor support.
Standardize all STT, TTS, and LLM service classes to declare `_settings` with the narrowed Settings type as a class-level annotation. This gives editors and type checkers the specific type when hovering or autocompleting on `self._settings` in each service and its subclasses. Inline `self._settings: Type = ...` assignments are replaced with plain `self._settings = ...`.
This commit is contained in:
@@ -129,6 +129,8 @@ class AnthropicLLMService(LLMService):
|
||||
Can use custom clients like AsyncAnthropicBedrock and AsyncAnthropicVertex.
|
||||
"""
|
||||
|
||||
_settings: AnthropicLLMSettings
|
||||
|
||||
# Overriding the default adapter to use the Anthropic one.
|
||||
adapter_class = AnthropicLLMAdapter
|
||||
|
||||
|
||||
@@ -75,6 +75,8 @@ class AssemblyAISTTService(WebsocketSTTService):
|
||||
for audio processing and connection management.
|
||||
"""
|
||||
|
||||
_settings: AssemblyAISTTSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@@ -111,7 +113,7 @@ class AssemblyAISTTService(WebsocketSTTService):
|
||||
)
|
||||
|
||||
self._api_key = api_key
|
||||
self._settings: AssemblyAISTTSettings = AssemblyAISTTSettings(
|
||||
self._settings = AssemblyAISTTSettings(
|
||||
language=language,
|
||||
connection_params=connection_params,
|
||||
)
|
||||
|
||||
@@ -95,6 +95,8 @@ class AsyncAITTSService(AudioContextTTSService):
|
||||
Provides text-to-speech using Async's streaming WebSocket API.
|
||||
"""
|
||||
|
||||
_settings: AsyncAITTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for Async TTS configuration.
|
||||
|
||||
@@ -148,7 +150,7 @@ class AsyncAITTSService(AudioContextTTSService):
|
||||
self._api_key = api_key
|
||||
self._api_version = version
|
||||
self._url = url
|
||||
self._settings: AsyncAITTSSettings = AsyncAITTSSettings(
|
||||
self._settings = AsyncAITTSSettings(
|
||||
model=model,
|
||||
voice=voice_id,
|
||||
output_format={
|
||||
@@ -431,6 +433,8 @@ class AsyncAIHttpTTSService(TTSService):
|
||||
connection is not required or desired.
|
||||
"""
|
||||
|
||||
_settings: AsyncAITTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for Async API.
|
||||
|
||||
@@ -477,7 +481,7 @@ class AsyncAIHttpTTSService(TTSService):
|
||||
self._api_key = api_key
|
||||
self._base_url = url
|
||||
self._api_version = version
|
||||
self._settings: AsyncAITTSSettings = AsyncAITTSSettings(
|
||||
self._settings = AsyncAITTSSettings(
|
||||
model=model,
|
||||
voice=voice_id,
|
||||
output_container=container,
|
||||
|
||||
@@ -743,6 +743,8 @@ class AWSBedrockLLMService(LLMService):
|
||||
vision capabilities.
|
||||
"""
|
||||
|
||||
_settings: AWSBedrockLLMSettings
|
||||
|
||||
# Overriding the default adapter to use the Anthropic one.
|
||||
adapter_class = AWSBedrockLLMAdapter
|
||||
|
||||
|
||||
@@ -72,6 +72,8 @@ class AWSTranscribeSTTService(WebsocketSTTService):
|
||||
final transcription results.
|
||||
"""
|
||||
|
||||
_settings: AWSTranscribeSTTSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@@ -99,7 +101,7 @@ class AWSTranscribeSTTService(WebsocketSTTService):
|
||||
"""
|
||||
super().__init__(ttfs_p99_latency=ttfs_p99_latency, **kwargs)
|
||||
|
||||
self._settings: AWSTranscribeSTTSettings = AWSTranscribeSTTSettings(
|
||||
self._settings = AWSTranscribeSTTSettings(
|
||||
language=language,
|
||||
sample_rate=sample_rate,
|
||||
media_encoding="linear16",
|
||||
|
||||
@@ -150,6 +150,8 @@ class AWSPollyTTSService(TTSService):
|
||||
options including prosody controls.
|
||||
"""
|
||||
|
||||
_settings: AWSPollyTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for AWS Polly TTS configuration.
|
||||
|
||||
@@ -206,7 +208,7 @@ class AWSPollyTTSService(TTSService):
|
||||
}
|
||||
|
||||
self._aws_session = aioboto3.Session()
|
||||
self._settings: AWSPollyTTSSettings = AWSPollyTTSSettings(
|
||||
self._settings = AWSPollyTTSSettings(
|
||||
voice=voice_id,
|
||||
engine=params.engine,
|
||||
language=self.language_to_service_language(params.language)
|
||||
|
||||
@@ -71,6 +71,8 @@ class AzureSTTService(STTService):
|
||||
provides real-time transcription results with timing information.
|
||||
"""
|
||||
|
||||
_settings: AzureSTTSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@@ -107,7 +109,7 @@ class AzureSTTService(STTService):
|
||||
|
||||
self._audio_stream = None
|
||||
self._speech_recognizer = None
|
||||
self._settings: AzureSTTSettings = AzureSTTSettings(
|
||||
self._settings = AzureSTTSettings(
|
||||
region=region,
|
||||
language=language_to_azure_language(language),
|
||||
sample_rate=sample_rate,
|
||||
|
||||
@@ -100,6 +100,8 @@ class AzureBaseTTSService:
|
||||
This is a mixin class and should be used alongside TTSService or its subclasses.
|
||||
"""
|
||||
|
||||
_settings: AzureTTSSettings
|
||||
|
||||
# Define SSML escape mappings based on SSML reserved characters
|
||||
# See - https://learn.microsoft.com/en-us/azure/ai-services/speech-service/speech-synthesis-markup-structure
|
||||
SSML_ESCAPE_CHARS = {
|
||||
@@ -153,7 +155,7 @@ class AzureBaseTTSService:
|
||||
"""
|
||||
params = params or AzureBaseTTSService.InputParams()
|
||||
|
||||
self._settings: AzureTTSSettings = AzureTTSSettings(
|
||||
self._settings = AzureTTSSettings(
|
||||
emphasis=params.emphasis,
|
||||
language=self.language_to_service_language(params.language)
|
||||
if params.language
|
||||
|
||||
@@ -170,6 +170,8 @@ class CambTTSService(TTSService):
|
||||
)
|
||||
"""
|
||||
|
||||
_settings: CambTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for Camb.ai TTS configuration.
|
||||
|
||||
@@ -226,7 +228,7 @@ class CambTTSService(TTSService):
|
||||
)
|
||||
|
||||
# Build settings
|
||||
self._settings: CambTTSSettings = CambTTSSettings(
|
||||
self._settings = CambTTSSettings(
|
||||
model=model,
|
||||
voice=voice_id,
|
||||
language=(
|
||||
|
||||
@@ -149,6 +149,8 @@ class CartesiaSTTService(WebsocketSTTService):
|
||||
See: https://docs.cartesia.ai/api-reference/stt/stt
|
||||
"""
|
||||
|
||||
_settings: CartesiaSTTSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@@ -194,7 +196,7 @@ class CartesiaSTTService(WebsocketSTTService):
|
||||
k: v for k, v in merged_options.items() if not isinstance(v, str) or v != "None"
|
||||
}
|
||||
|
||||
self._settings: CartesiaSTTSettings = CartesiaSTTSettings(
|
||||
self._settings = CartesiaSTTSettings(
|
||||
model=merged_options["model"],
|
||||
language=merged_options.get("language"),
|
||||
encoding=merged_options.get("encoding", "pcm_s16le"),
|
||||
|
||||
@@ -226,6 +226,8 @@ class CartesiaTTSService(AudioContextWordTTSService):
|
||||
customization options including speed and emotion controls.
|
||||
"""
|
||||
|
||||
_settings: CartesiaTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for Cartesia TTS configuration.
|
||||
|
||||
@@ -316,7 +318,7 @@ class CartesiaTTSService(AudioContextWordTTSService):
|
||||
self._api_key = api_key
|
||||
self._cartesia_version = cartesia_version
|
||||
self._url = url
|
||||
self._settings: CartesiaTTSSettings = CartesiaTTSSettings(
|
||||
self._settings = CartesiaTTSSettings(
|
||||
output_container=container,
|
||||
output_encoding=encoding,
|
||||
output_sample_rate=0,
|
||||
@@ -655,6 +657,8 @@ class CartesiaHttpTTSService(TTSService):
|
||||
integration is preferred.
|
||||
"""
|
||||
|
||||
_settings: CartesiaTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for Cartesia HTTP TTS configuration.
|
||||
|
||||
@@ -712,7 +716,7 @@ class CartesiaHttpTTSService(TTSService):
|
||||
self._api_key = api_key
|
||||
self._base_url = base_url
|
||||
self._cartesia_version = cartesia_version
|
||||
self._settings: CartesiaTTSSettings = CartesiaTTSSettings(
|
||||
self._settings = CartesiaTTSSettings(
|
||||
model=model,
|
||||
voice=voice_id,
|
||||
output_container=container,
|
||||
|
||||
@@ -65,6 +65,8 @@ class DeepgramSTTService(STTService):
|
||||
Supports configurable models, languages, and various audio processing options.
|
||||
"""
|
||||
|
||||
_settings: DeepgramSTTSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@@ -143,7 +145,7 @@ class DeepgramSTTService(STTService):
|
||||
|
||||
self.set_model_name(merged_options["model"])
|
||||
merged_live_options = LiveOptions(**merged_options)
|
||||
self._settings: DeepgramSTTSettings = DeepgramSTTSettings(
|
||||
self._settings = DeepgramSTTSettings(
|
||||
model=merged_options.get("model"),
|
||||
language=merged_options.get("language"),
|
||||
live_options=merged_live_options,
|
||||
|
||||
@@ -88,6 +88,8 @@ class DeepgramSageMakerSTTService(STTService):
|
||||
)
|
||||
"""
|
||||
|
||||
_settings: DeepgramSageMakerSTTSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@@ -143,7 +145,7 @@ class DeepgramSageMakerSTTService(STTService):
|
||||
|
||||
self.set_model_name(merged_options["model"])
|
||||
merged_live_options = LiveOptions(**merged_options)
|
||||
self._settings: DeepgramSageMakerSTTSettings = DeepgramSageMakerSTTSettings(
|
||||
self._settings = DeepgramSageMakerSTTSettings(
|
||||
model=merged_options.get("model"),
|
||||
language=merged_options.get("language"),
|
||||
live_options=merged_live_options,
|
||||
|
||||
@@ -64,6 +64,8 @@ class DeepgramTTSService(WebsocketTTSService):
|
||||
message for conversational AI use cases.
|
||||
"""
|
||||
|
||||
_settings: DeepgramTTSSettings
|
||||
|
||||
SUPPORTED_ENCODINGS = ("linear16", "mulaw", "alaw")
|
||||
|
||||
def __init__(
|
||||
@@ -104,7 +106,7 @@ class DeepgramTTSService(WebsocketTTSService):
|
||||
|
||||
self._api_key = api_key
|
||||
self._base_url = base_url
|
||||
self._settings: DeepgramTTSSettings = DeepgramTTSSettings(
|
||||
self._settings = DeepgramTTSSettings(
|
||||
model=voice,
|
||||
voice=voice,
|
||||
encoding=encoding,
|
||||
@@ -345,6 +347,8 @@ class DeepgramHttpTTSService(TTSService):
|
||||
configurable sample rates and quality settings.
|
||||
"""
|
||||
|
||||
_settings: DeepgramTTSSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@@ -372,7 +376,7 @@ class DeepgramHttpTTSService(TTSService):
|
||||
self._api_key = api_key
|
||||
self._session = aiohttp_session
|
||||
self._base_url = base_url
|
||||
self._settings: DeepgramTTSSettings = DeepgramTTSSettings(
|
||||
self._settings = DeepgramTTSSettings(
|
||||
model=voice,
|
||||
voice=voice,
|
||||
encoding=encoding,
|
||||
|
||||
@@ -215,6 +215,8 @@ class ElevenLabsSTTService(SegmentedSTTService):
|
||||
The service uploads audio files to ElevenLabs and receives transcription results directly.
|
||||
"""
|
||||
|
||||
_settings: ElevenLabsSTTSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Configuration parameters for ElevenLabs STT API.
|
||||
|
||||
@@ -264,7 +266,7 @@ class ElevenLabsSTTService(SegmentedSTTService):
|
||||
self._session = aiohttp_session
|
||||
self._model_id = model
|
||||
|
||||
self._settings: ElevenLabsSTTSettings = ElevenLabsSTTSettings(
|
||||
self._settings = ElevenLabsSTTSettings(
|
||||
model=model,
|
||||
language=self.language_to_service_language(params.language)
|
||||
if params.language
|
||||
@@ -449,6 +451,8 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService):
|
||||
commit transcript segments, providing consistency with other STT services.
|
||||
"""
|
||||
|
||||
_settings: ElevenLabsRealtimeSTTSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Configuration parameters for ElevenLabs Realtime STT API.
|
||||
|
||||
@@ -517,7 +521,7 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService):
|
||||
self._audio_format = "" # initialized in start()
|
||||
self._receive_task = None
|
||||
|
||||
self._settings: ElevenLabsRealtimeSTTSettings = ElevenLabsRealtimeSTTSettings(
|
||||
self._settings = ElevenLabsRealtimeSTTSettings(
|
||||
model=model,
|
||||
language=params.language_code,
|
||||
commit_strategy=params.commit_strategy,
|
||||
|
||||
@@ -321,6 +321,8 @@ class ElevenLabsTTSService(AudioContextWordTTSService):
|
||||
customization options including stability, similarity boost, and speed controls.
|
||||
"""
|
||||
|
||||
_settings: ElevenLabsTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for ElevenLabs TTS configuration.
|
||||
|
||||
@@ -401,7 +403,7 @@ class ElevenLabsTTSService(AudioContextWordTTSService):
|
||||
|
||||
self._api_key = api_key
|
||||
self._url = url
|
||||
self._settings: ElevenLabsTTSSettings = ElevenLabsTTSSettings(
|
||||
self._settings = ElevenLabsTTSSettings(
|
||||
model=model,
|
||||
voice=voice_id,
|
||||
language=(
|
||||
@@ -836,6 +838,8 @@ class ElevenLabsHttpTTSService(WordTTSService):
|
||||
connection is not required or desired.
|
||||
"""
|
||||
|
||||
_settings: ElevenLabsHttpTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for ElevenLabs HTTP TTS configuration.
|
||||
|
||||
@@ -902,7 +906,7 @@ class ElevenLabsHttpTTSService(WordTTSService):
|
||||
self._params = params
|
||||
self._session = aiohttp_session
|
||||
|
||||
self._settings: ElevenLabsHttpTTSSettings = ElevenLabsHttpTTSSettings(
|
||||
self._settings = ElevenLabsHttpTTSSettings(
|
||||
model=model,
|
||||
voice=voice_id,
|
||||
language=self.language_to_service_language(params.language)
|
||||
|
||||
@@ -171,6 +171,8 @@ class FalSTTService(SegmentedSTTService):
|
||||
segments. It inherits from SegmentedSTTService to handle audio buffering and speech detection.
|
||||
"""
|
||||
|
||||
_settings: FalSTTSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Configuration parameters for Fal's Wizper API.
|
||||
|
||||
@@ -221,7 +223,7 @@ class FalSTTService(SegmentedSTTService):
|
||||
)
|
||||
|
||||
self._fal_client = fal_client.AsyncClient(key=api_key or os.getenv("FAL_KEY"))
|
||||
self._settings: FalSTTSettings = FalSTTSettings(
|
||||
self._settings = FalSTTSettings(
|
||||
language=self.language_to_service_language(params.language)
|
||||
if params.language
|
||||
else "en",
|
||||
|
||||
@@ -78,6 +78,8 @@ class FishAudioTTSService(InterruptibleTTSService):
|
||||
audio generation with interruption handling.
|
||||
"""
|
||||
|
||||
_settings: FishAudioTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for Fish Audio TTS configuration.
|
||||
|
||||
@@ -161,7 +163,7 @@ class FishAudioTTSService(InterruptibleTTSService):
|
||||
self._receive_task = None
|
||||
self._request_id = None
|
||||
|
||||
self._settings: FishAudioTTSSettings = FishAudioTTSSettings(
|
||||
self._settings = FishAudioTTSSettings(
|
||||
voice=reference_id,
|
||||
fish_sample_rate=0,
|
||||
latency=params.latency,
|
||||
|
||||
@@ -204,6 +204,8 @@ class GladiaSTTService(WebsocketSTTService):
|
||||
Use :class:`~pipecat.services.gladia.config.GladiaInputParams` directly instead.
|
||||
"""
|
||||
|
||||
_settings: GladiaSTTSettings
|
||||
|
||||
# Maintain backward compatibility
|
||||
InputParams = _InputParamsDescriptor()
|
||||
|
||||
|
||||
@@ -635,6 +635,8 @@ class GeminiLiveLLMService(LLMService):
|
||||
responses, and tool usage.
|
||||
"""
|
||||
|
||||
_settings: GeminiLiveLLMSettings
|
||||
|
||||
# Overriding the default adapter to use the Gemini one.
|
||||
adapter_class = GeminiLLMAdapter
|
||||
|
||||
|
||||
@@ -692,6 +692,8 @@ class GoogleLLMService(LLMService):
|
||||
expected by the Google AI model.
|
||||
"""
|
||||
|
||||
_settings: GoogleLLMSettings
|
||||
|
||||
# Overriding the default adapter to use the Gemini one.
|
||||
adapter_class = GeminiLLMAdapter
|
||||
|
||||
|
||||
@@ -412,6 +412,8 @@ class GoogleSTTService(STTService):
|
||||
ValueError: If project ID is not found in credentials.
|
||||
"""
|
||||
|
||||
_settings: GoogleSTTSettings
|
||||
|
||||
# Google Cloud's STT service has a connection time limit of 5 minutes per stream.
|
||||
# They've shared an "endless streaming" example that guided this implementation:
|
||||
# https://cloud.google.com/speech-to-text/docs/transcribe-streaming-audio#endless-streaming
|
||||
|
||||
@@ -547,6 +547,8 @@ class GoogleHttpTTSService(TTSService):
|
||||
Chirp and Journey voices don't support SSML and will use plain text input.
|
||||
"""
|
||||
|
||||
_settings: GoogleHttpTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for Google HTTP TTS voice customization.
|
||||
|
||||
@@ -597,7 +599,7 @@ class GoogleHttpTTSService(TTSService):
|
||||
params = params or GoogleHttpTTSService.InputParams()
|
||||
|
||||
self._location = location
|
||||
self._settings: GoogleHttpTTSSettings = GoogleHttpTTSSettings(
|
||||
self._settings = GoogleHttpTTSSettings(
|
||||
pitch=params.pitch,
|
||||
rate=params.rate,
|
||||
speaking_rate=params.speaking_rate,
|
||||
@@ -968,6 +970,8 @@ class GoogleTTSService(GoogleBaseTTSService):
|
||||
)
|
||||
"""
|
||||
|
||||
_settings: GoogleStreamTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for Google streaming TTS configuration.
|
||||
|
||||
@@ -1008,7 +1012,7 @@ class GoogleTTSService(GoogleBaseTTSService):
|
||||
params = params or GoogleTTSService.InputParams()
|
||||
|
||||
self._location = location
|
||||
self._settings: GoogleStreamTTSSettings = GoogleStreamTTSSettings(
|
||||
self._settings = GoogleStreamTTSSettings(
|
||||
language=self.language_to_service_language(params.language)
|
||||
if params.language
|
||||
else "en-US",
|
||||
@@ -1109,6 +1113,8 @@ class GeminiTTSService(GoogleBaseTTSService):
|
||||
)
|
||||
"""
|
||||
|
||||
_settings: GeminiTTSSettings
|
||||
|
||||
GOOGLE_SAMPLE_RATE = 24000 # Google TTS always outputs at 24kHz
|
||||
|
||||
# List of available Gemini TTS voices
|
||||
@@ -1216,7 +1222,7 @@ class GeminiTTSService(GoogleBaseTTSService):
|
||||
self._location = location
|
||||
self._model = model
|
||||
self._voice_id = voice_id
|
||||
self._settings: GeminiTTSSettings = GeminiTTSSettings(
|
||||
self._settings = GeminiTTSSettings(
|
||||
language=self.language_to_service_language(params.language)
|
||||
if params.language
|
||||
else "en-US",
|
||||
|
||||
@@ -86,6 +86,8 @@ class GradiumSTTService(WebsocketSTTService):
|
||||
for audio processing and connection management.
|
||||
"""
|
||||
|
||||
_settings: GradiumSTTSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Configuration parameters for Gradium STT API.
|
||||
|
||||
@@ -145,7 +147,7 @@ class GradiumSTTService(WebsocketSTTService):
|
||||
|
||||
params = params or GradiumSTTService.InputParams()
|
||||
|
||||
self._settings: GradiumSTTSettings = GradiumSTTSettings(
|
||||
self._settings = GradiumSTTSettings(
|
||||
language=params.language,
|
||||
delay_in_frames=params.delay_in_frames if params.delay_in_frames else NOT_GIVEN,
|
||||
)
|
||||
|
||||
@@ -53,6 +53,8 @@ class GradiumTTSSettings(TTSSettings):
|
||||
class GradiumTTSService(InterruptibleWordTTSService):
|
||||
"""Text-to-Speech service using Gradium's websocket API."""
|
||||
|
||||
_settings: GradiumTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Configuration parameters for Gradium TTS service.
|
||||
|
||||
@@ -99,7 +101,7 @@ class GradiumTTSService(InterruptibleWordTTSService):
|
||||
self._url = url
|
||||
self._voice_id = voice_id
|
||||
self._json_config = json_config
|
||||
self._settings: GradiumTTSSettings = GradiumTTSSettings(
|
||||
self._settings = GradiumTTSSettings(
|
||||
model=model,
|
||||
voice=voice_id,
|
||||
output_format="pcm",
|
||||
|
||||
@@ -113,6 +113,8 @@ class GrokRealtimeLLMService(LLMService):
|
||||
- Server-side VAD (Voice Activity Detection)
|
||||
"""
|
||||
|
||||
_settings: GrokRealtimeLLMSettings
|
||||
|
||||
# Use the Grok-specific adapter
|
||||
adapter_class = GrokRealtimeLLMAdapter
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ class GroqTTSService(TTSService):
|
||||
and output formats.
|
||||
"""
|
||||
|
||||
_settings: GroqTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for Groq TTS configuration.
|
||||
|
||||
@@ -109,7 +111,7 @@ class GroqTTSService(TTSService):
|
||||
self._voice_id = voice_id
|
||||
self._params = params
|
||||
|
||||
self._settings: GroqTTSSettings = GroqTTSSettings(
|
||||
self._settings = GroqTTSSettings(
|
||||
model=model_name,
|
||||
voice=voice_id,
|
||||
language=str(params.language) if params.language else "en",
|
||||
|
||||
@@ -48,6 +48,8 @@ class HathoraSTTService(SegmentedSTTService):
|
||||
[Documentation](https://models.hathora.dev)
|
||||
"""
|
||||
|
||||
_settings: HathoraSTTSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Optional input parameters for Hathora STT configuration.
|
||||
|
||||
@@ -98,7 +100,7 @@ class HathoraSTTService(SegmentedSTTService):
|
||||
|
||||
params = params or HathoraSTTService.InputParams()
|
||||
|
||||
self._settings: HathoraSTTSettings = HathoraSTTSettings(
|
||||
self._settings = HathoraSTTSettings(
|
||||
model=model,
|
||||
language=params.language,
|
||||
config=params.config,
|
||||
|
||||
@@ -68,6 +68,8 @@ class HathoraTTSService(TTSService):
|
||||
[Documentation](https://models.hathora.dev)
|
||||
"""
|
||||
|
||||
_settings: HathoraTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Optional input parameters for Hathora TTS configuration.
|
||||
|
||||
@@ -115,7 +117,7 @@ class HathoraTTSService(TTSService):
|
||||
|
||||
params = params or HathoraTTSService.InputParams()
|
||||
|
||||
self._settings: HathoraTTSSettings = HathoraTTSSettings(
|
||||
self._settings = HathoraTTSSettings(
|
||||
model=model,
|
||||
voice=voice_id,
|
||||
speed=params.speed,
|
||||
|
||||
@@ -82,6 +82,8 @@ class InworldHttpTTSService(WordTTSService):
|
||||
Outputs LINEAR16 audio at configurable sample rates with word-level timestamps.
|
||||
"""
|
||||
|
||||
_settings: InworldTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for Inworld TTS configuration.
|
||||
|
||||
@@ -138,7 +140,7 @@ class InworldHttpTTSService(WordTTSService):
|
||||
else:
|
||||
self._base_url = "https://api.inworld.ai/tts/v1/voice"
|
||||
|
||||
self._settings: InworldTTSSettings = InworldTTSSettings(
|
||||
self._settings = InworldTTSSettings(
|
||||
model=model,
|
||||
voice=voice_id,
|
||||
audio_encoding=encoding,
|
||||
@@ -438,6 +440,8 @@ class InworldTTSService(AudioContextWordTTSService):
|
||||
with word-level timestamps.
|
||||
"""
|
||||
|
||||
_settings: InworldTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for Inworld WebSocket TTS configuration.
|
||||
|
||||
@@ -503,7 +507,7 @@ class InworldTTSService(AudioContextWordTTSService):
|
||||
|
||||
self._api_key = api_key
|
||||
self._url = url
|
||||
self._settings: InworldTTSSettings = InworldTTSSettings(
|
||||
self._settings = InworldTTSSettings(
|
||||
model=model,
|
||||
voice=voice_id,
|
||||
audio_encoding=encoding,
|
||||
|
||||
@@ -107,6 +107,8 @@ class KokoroTTSService(TTSService):
|
||||
Automatically downloads model files on first use.
|
||||
"""
|
||||
|
||||
_settings: KokoroTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for Kokoro TTS configuration.
|
||||
|
||||
@@ -142,7 +144,7 @@ class KokoroTTSService(TTSService):
|
||||
self._voice_id = voice_id
|
||||
self._lang_code = language_to_kokoro_language(params.language)
|
||||
|
||||
self._settings: KokoroTTSSettings = KokoroTTSSettings(
|
||||
self._settings = KokoroTTSSettings(
|
||||
voice=voice_id,
|
||||
language=language_to_kokoro_language(params.language),
|
||||
lang_code=language_to_kokoro_language(params.language),
|
||||
|
||||
@@ -174,6 +174,8 @@ class LLMService(UserTurnCompletionLLMServiceMixin, AIService):
|
||||
logger.info(f"Starting {len(function_calls)} function calls")
|
||||
"""
|
||||
|
||||
_settings: LLMSettings
|
||||
|
||||
# OpenAILLMAdapter is used as the default adapter since it aligns with most LLM implementations.
|
||||
# However, subclasses should override this with a more specific adapter when necessary.
|
||||
adapter_class: Type[BaseLLMAdapter] = OpenAILLMAdapter
|
||||
|
||||
@@ -92,6 +92,8 @@ class LmntTTSService(InterruptibleTTSService):
|
||||
language settings.
|
||||
"""
|
||||
|
||||
_settings: LmntTTSSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@@ -122,7 +124,7 @@ class LmntTTSService(InterruptibleTTSService):
|
||||
self._api_key = api_key
|
||||
self._voice_id = voice_id
|
||||
self.set_model_name(model)
|
||||
self._settings: LmntTTSSettings = LmntTTSSettings(
|
||||
self._settings = LmntTTSSettings(
|
||||
model=model,
|
||||
voice=voice_id,
|
||||
language=self.language_to_service_language(language),
|
||||
|
||||
@@ -132,6 +132,8 @@ class MiniMaxHttpTTSService(TTSService):
|
||||
https://www.minimax.io/platform/document/T2A%20V2?key=66719005a427f0c8a5701643
|
||||
"""
|
||||
|
||||
_settings: MiniMaxTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Configuration parameters for MiniMax TTS.
|
||||
|
||||
@@ -208,7 +210,7 @@ class MiniMaxHttpTTSService(TTSService):
|
||||
self._voice_id = voice_id
|
||||
|
||||
# Create voice settings
|
||||
self._settings: MiniMaxTTSSettings = MiniMaxTTSSettings(
|
||||
self._settings = MiniMaxTTSSettings(
|
||||
model=model,
|
||||
voice=voice_id,
|
||||
stream=True,
|
||||
|
||||
@@ -99,6 +99,8 @@ class NeuphonicTTSService(InterruptibleTTSService):
|
||||
parameters for high-quality speech generation.
|
||||
"""
|
||||
|
||||
_settings: NeuphonicTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for Neuphonic TTS configuration.
|
||||
|
||||
@@ -146,7 +148,7 @@ class NeuphonicTTSService(InterruptibleTTSService):
|
||||
|
||||
self._api_key = api_key
|
||||
self._url = url
|
||||
self._settings: NeuphonicTTSSettings = NeuphonicTTSSettings(
|
||||
self._settings = NeuphonicTTSSettings(
|
||||
lang_code=self.language_to_service_language(params.language),
|
||||
speed=params.speed,
|
||||
encoding=encoding,
|
||||
|
||||
@@ -125,6 +125,8 @@ class NvidiaSTTService(STTService):
|
||||
processing for low-latency applications.
|
||||
"""
|
||||
|
||||
_settings: NvidiaSTTSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Configuration parameters for NVIDIA Riva STT service.
|
||||
|
||||
@@ -178,7 +180,7 @@ class NvidiaSTTService(STTService):
|
||||
self._custom_configuration = ""
|
||||
self._function_id = model_function_map.get("function_id")
|
||||
|
||||
self._settings: NvidiaSTTSettings = NvidiaSTTSettings(
|
||||
self._settings = NvidiaSTTSettings(
|
||||
language=params.language,
|
||||
)
|
||||
|
||||
@@ -399,6 +401,8 @@ class NvidiaSegmentedSTTService(SegmentedSTTService):
|
||||
audio buffering and speech detection.
|
||||
"""
|
||||
|
||||
_settings: NvidiaSegmentedSTTSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Configuration parameters for NVIDIA Riva segmented STT service.
|
||||
|
||||
@@ -470,7 +474,7 @@ class NvidiaSegmentedSTTService(SegmentedSTTService):
|
||||
|
||||
self._config = None
|
||||
self._asr_service = None
|
||||
self._settings: NvidiaSegmentedSTTSettings = NvidiaSegmentedSTTSettings(
|
||||
self._settings = NvidiaSegmentedSTTSettings(
|
||||
language=params.language or Language.EN_US,
|
||||
profanity_filter=params.profanity_filter,
|
||||
automatic_punctuation=params.automatic_punctuation,
|
||||
|
||||
@@ -70,6 +70,8 @@ class BaseOpenAILLMService(LLMService):
|
||||
configurations.
|
||||
"""
|
||||
|
||||
_settings: OpenAILLMSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for OpenAI model configuration.
|
||||
|
||||
|
||||
@@ -110,6 +110,8 @@ class OpenAIRealtimeLLMService(LLMService):
|
||||
management, and real-time transcription.
|
||||
"""
|
||||
|
||||
_settings: OpenAIRealtimeLLMSettings
|
||||
|
||||
# Overriding the default adapter to use the OpenAIRealtimeLLMAdapter one.
|
||||
adapter_class = OpenAIRealtimeLLMAdapter
|
||||
|
||||
|
||||
@@ -169,6 +169,8 @@ class OpenAIRealtimeSTTService(WebsocketSTTService):
|
||||
)
|
||||
"""
|
||||
|
||||
_settings: OpenAIRealtimeSTTSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@@ -231,7 +233,7 @@ class OpenAIRealtimeSTTService(WebsocketSTTService):
|
||||
self._noise_reduction = noise_reduction
|
||||
self._should_interrupt = should_interrupt
|
||||
|
||||
self._settings: OpenAIRealtimeSTTSettings = OpenAIRealtimeSTTSettings(
|
||||
self._settings = OpenAIRealtimeSTTSettings(
|
||||
model=model,
|
||||
language=language,
|
||||
prompt=prompt,
|
||||
|
||||
@@ -83,6 +83,8 @@ class OpenAITTSService(TTSService):
|
||||
speech synthesis with streaming audio output.
|
||||
"""
|
||||
|
||||
_settings: OpenAITTSSettings
|
||||
|
||||
OPENAI_SAMPLE_RATE = 24000 # OpenAI TTS always outputs at 24kHz
|
||||
|
||||
class InputParams(BaseModel):
|
||||
@@ -147,7 +149,7 @@ class OpenAITTSService(TTSService):
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
self._settings: OpenAITTSSettings = OpenAITTSSettings(
|
||||
self._settings = OpenAITTSSettings(
|
||||
model=model,
|
||||
voice=voice,
|
||||
instructions=params.instructions if params else instructions,
|
||||
|
||||
@@ -115,6 +115,8 @@ class OpenAIRealtimeBetaLLMService(LLMService):
|
||||
management, and real-time transcription.
|
||||
"""
|
||||
|
||||
_settings: OpenAIRealtimeBetaLLMSettings
|
||||
|
||||
# Overriding the default adapter to use the OpenAIRealtimeLLMAdapter one.
|
||||
adapter_class = OpenAIRealtimeLLMAdapter
|
||||
|
||||
|
||||
@@ -131,6 +131,8 @@ class PlayHTTTSService(InterruptibleTTSService):
|
||||
language settings.
|
||||
"""
|
||||
|
||||
_settings: PlayHTTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for PlayHT TTS configuration.
|
||||
|
||||
@@ -191,7 +193,7 @@ class PlayHTTTSService(InterruptibleTTSService):
|
||||
self._receive_task = None
|
||||
self._context_id = None
|
||||
|
||||
self._settings: PlayHTTTSSettings = PlayHTTTSSettings(
|
||||
self._settings = PlayHTTTSSettings(
|
||||
model=voice_engine,
|
||||
voice=voice_url,
|
||||
language=self.language_to_service_language(params.language)
|
||||
@@ -444,6 +446,8 @@ class PlayHTHttpTTSService(TTSService):
|
||||
required and simpler integration is preferred.
|
||||
"""
|
||||
|
||||
_settings: PlayHTTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for PlayHT HTTP TTS configuration.
|
||||
|
||||
@@ -522,7 +526,7 @@ class PlayHTHttpTTSService(TTSService):
|
||||
# Extract the base engine name
|
||||
voice_engine = voice_engine.replace("-ws", "")
|
||||
|
||||
self._settings: PlayHTTTSSettings = PlayHTTTSSettings(
|
||||
self._settings = PlayHTTTSSettings(
|
||||
voice=voice_url,
|
||||
language=self.language_to_service_language(params.language)
|
||||
if params.language
|
||||
|
||||
@@ -63,6 +63,8 @@ class ResembleAITTSService(AudioContextWordTTSService):
|
||||
multiple simultaneous synthesis requests with proper interruption support.
|
||||
"""
|
||||
|
||||
_settings: ResembleAITTSSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@@ -93,7 +95,7 @@ class ResembleAITTSService(AudioContextWordTTSService):
|
||||
self._api_key = api_key
|
||||
self._voice_id = voice_id
|
||||
self._url = url
|
||||
self._settings: ResembleAITTSSettings = ResembleAITTSSettings(
|
||||
self._settings = ResembleAITTSSettings(
|
||||
voice=voice_id,
|
||||
precision=precision,
|
||||
output_format=output_format,
|
||||
|
||||
@@ -134,6 +134,8 @@ class RimeTTSService(AudioContextWordTTSService):
|
||||
within a turn.
|
||||
"""
|
||||
|
||||
_settings: RimeTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Configuration parameters for Rime TTS service.
|
||||
|
||||
@@ -207,7 +209,7 @@ class RimeTTSService(AudioContextWordTTSService):
|
||||
self._url = url
|
||||
self._voice_id = voice_id
|
||||
self._model = model
|
||||
self._settings: RimeTTSSettings = RimeTTSSettings(
|
||||
self._settings = RimeTTSSettings(
|
||||
speaker=voice_id,
|
||||
modelId=model,
|
||||
audioFormat="pcm",
|
||||
@@ -537,6 +539,8 @@ class RimeHttpTTSService(TTSService):
|
||||
Suitable for use cases where streaming is not required.
|
||||
"""
|
||||
|
||||
_settings: RimeTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Configuration parameters for Rime HTTP TTS service.
|
||||
|
||||
@@ -585,7 +589,7 @@ class RimeHttpTTSService(TTSService):
|
||||
self._api_key = api_key
|
||||
self._session = aiohttp_session
|
||||
self._base_url = "https://users.rime.ai/v1/rime-tts"
|
||||
self._settings: RimeTTSSettings = RimeTTSSettings(
|
||||
self._settings = RimeTTSSettings(
|
||||
lang=self.language_to_service_language(params.language) if params.language else "eng",
|
||||
speedAlpha=params.speed_alpha,
|
||||
reduceLatency=params.reduce_latency,
|
||||
@@ -706,6 +710,8 @@ class RimeNonJsonTTSService(InterruptibleTTSService):
|
||||
future. This service focuses on the current plain text protocol.
|
||||
"""
|
||||
|
||||
_settings: RimeNonJsonTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Configuration parameters for Rime Non-JSON WebSocket TTS service.
|
||||
|
||||
@@ -763,7 +769,7 @@ class RimeNonJsonTTSService(InterruptibleTTSService):
|
||||
self._url = url
|
||||
self._voice_id = voice_id
|
||||
self._model = model
|
||||
self._settings: RimeNonJsonTTSSettings = RimeNonJsonTTSSettings(
|
||||
self._settings = RimeNonJsonTTSSettings(
|
||||
speaker=voice_id,
|
||||
modelId=model,
|
||||
audioFormat=audio_format,
|
||||
|
||||
@@ -154,6 +154,8 @@ class SarvamSTTService(STTService):
|
||||
Provides real-time speech recognition using Sarvam's WebSocket API.
|
||||
"""
|
||||
|
||||
_settings: SarvamSTTSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Configuration parameters for Sarvam STT service.
|
||||
|
||||
@@ -247,7 +249,7 @@ class SarvamSTTService(STTService):
|
||||
# Resolve mode default from model config
|
||||
mode = params.mode if params.mode is not None else self._config.default_mode
|
||||
|
||||
self._settings: SarvamSTTSettings = SarvamSTTSettings(
|
||||
self._settings = SarvamSTTSettings(
|
||||
model=model,
|
||||
language=params.language,
|
||||
prompt=params.prompt if params.prompt is not None else NOT_GIVEN,
|
||||
|
||||
@@ -371,6 +371,8 @@ class SarvamHttpTTSService(TTSService):
|
||||
)
|
||||
"""
|
||||
|
||||
_settings: SarvamHttpTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Input parameters for Sarvam TTS configuration.
|
||||
|
||||
@@ -478,7 +480,7 @@ class SarvamHttpTTSService(TTSService):
|
||||
pace = max(pace_min, min(pace_max, pace))
|
||||
|
||||
# Build base settings
|
||||
self._settings: SarvamHttpTTSSettings = SarvamHttpTTSSettings(
|
||||
self._settings = SarvamHttpTTSSettings(
|
||||
language=(
|
||||
self.language_to_service_language(params.language) if params.language else "en-IN"
|
||||
),
|
||||
@@ -684,6 +686,8 @@ class SarvamTTSService(InterruptibleTTSService):
|
||||
See https://docs.sarvam.ai/api-reference-docs/text-to-speech/stream for API details.
|
||||
"""
|
||||
|
||||
_settings: SarvamWSTTSSettings
|
||||
|
||||
class InputParams(BaseModel):
|
||||
"""Configuration parameters for Sarvam TTS WebSocket service.
|
||||
|
||||
@@ -837,7 +841,7 @@ class SarvamTTSService(InterruptibleTTSService):
|
||||
pace = max(pace_min, min(pace_max, pace))
|
||||
|
||||
# Build base settings
|
||||
self._settings: SarvamWSTTSSettings = SarvamWSTTSSettings(
|
||||
self._settings = SarvamWSTTSSettings(
|
||||
target_language_code=(
|
||||
self.language_to_service_language(params.language) if params.language else "en-IN"
|
||||
),
|
||||
|
||||
@@ -157,6 +157,8 @@ class SonioxSTTService(WebsocketSTTService):
|
||||
For complete API documentation, see: https://soniox.com/docs/speech-to-text/api-reference/websocket-api
|
||||
"""
|
||||
|
||||
_settings: SonioxSTTSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
||||
@@ -166,6 +166,8 @@ class SpeechmaticsSTTService(STTService):
|
||||
and speaker diarization.
|
||||
"""
|
||||
|
||||
_settings: SpeechmaticsSTTSettings
|
||||
|
||||
# Export related classes as class attributes
|
||||
TurnDetectionMode = TurnDetectionMode
|
||||
AudioEncoding = AudioEncoding
|
||||
|
||||
@@ -70,6 +70,8 @@ class STTService(AIService):
|
||||
logger.error(f"STT connection error: {error}")
|
||||
"""
|
||||
|
||||
_settings: STTSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
||||
@@ -104,6 +104,8 @@ class TTSService(AIService):
|
||||
logger.debug(f"TTS request: {context_id} - {text}")
|
||||
"""
|
||||
|
||||
_settings: TTSSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
||||
@@ -158,6 +158,8 @@ class UltravoxRealtimeLLMService(LLMService):
|
||||
by the model and may not always align with its understanding of user input.
|
||||
"""
|
||||
|
||||
_settings: UltravoxRealtimeLLMSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
||||
@@ -124,6 +124,8 @@ class BaseWhisperSTTService(SegmentedSTTService):
|
||||
including metrics generation and error handling.
|
||||
"""
|
||||
|
||||
_settings: BaseWhisperSTTSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@@ -161,7 +163,7 @@ class BaseWhisperSTTService(SegmentedSTTService):
|
||||
self._temperature = temperature
|
||||
self._include_prob_metrics = include_prob_metrics
|
||||
|
||||
self._settings: BaseWhisperSTTSettings = BaseWhisperSTTSettings(
|
||||
self._settings = BaseWhisperSTTSettings(
|
||||
model=model,
|
||||
language=self._language,
|
||||
base_url=base_url,
|
||||
|
||||
@@ -211,6 +211,8 @@ class WhisperSTTService(SegmentedSTTService):
|
||||
segments. It supports multiple languages and various model sizes.
|
||||
"""
|
||||
|
||||
_settings: WhisperSTTSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@@ -238,7 +240,7 @@ class WhisperSTTService(SegmentedSTTService):
|
||||
self._no_speech_prob = no_speech_prob
|
||||
self._model: Optional[WhisperModel] = None
|
||||
|
||||
self._settings: WhisperSTTSettings = WhisperSTTSettings(
|
||||
self._settings = WhisperSTTSettings(
|
||||
model=model if isinstance(model, str) else model.value,
|
||||
language=language,
|
||||
device=self._device,
|
||||
@@ -346,6 +348,8 @@ class WhisperSTTServiceMLX(WhisperSTTService):
|
||||
segments. It's optimized for Apple Silicon and supports multiple languages and quantizations.
|
||||
"""
|
||||
|
||||
_settings: WhisperMLXSTTSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@@ -371,7 +375,7 @@ class WhisperSTTServiceMLX(WhisperSTTService):
|
||||
self._no_speech_prob = no_speech_prob
|
||||
self._temperature = temperature
|
||||
|
||||
self._settings: WhisperMLXSTTSettings = WhisperMLXSTTSettings(
|
||||
self._settings = WhisperMLXSTTSettings(
|
||||
model=model if isinstance(model, str) else model.value,
|
||||
language=language,
|
||||
no_speech_prob=self._no_speech_prob,
|
||||
|
||||
@@ -89,6 +89,8 @@ class XTTSService(TTSService):
|
||||
studio speakers configuration.
|
||||
"""
|
||||
|
||||
_settings: XTTSTTSSettings
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@@ -111,7 +113,7 @@ class XTTSService(TTSService):
|
||||
"""
|
||||
super().__init__(sample_rate=sample_rate, **kwargs)
|
||||
|
||||
self._settings: XTTSTTSSettings = XTTSTTSSettings(
|
||||
self._settings = XTTSTTSSettings(
|
||||
voice=voice_id,
|
||||
language=self.language_to_service_language(language),
|
||||
base_url=base_url,
|
||||
|
||||
Reference in New Issue
Block a user