Actually, revert the change making it so that STTService takes model and language args at init time. It'll be up to the subclasses to append those to _settings (or better yet, provide their own service-specific _settings). This avoids rocking the boat too too much.
This commit is contained in:
@@ -291,7 +291,7 @@ class NewTTSService(TTSService):
|
||||
voice: Voice identifier to use.
|
||||
**kwargs: Additional arguments passed to the parent service.
|
||||
"""
|
||||
super().__init__(voice=voice, **kwargs)
|
||||
super().__init__(**kwargs)
|
||||
self._api_key = api_key
|
||||
```
|
||||
|
||||
|
||||
@@ -153,7 +153,6 @@ class AsyncAITTSService(AudioContextTTSService):
|
||||
pause_frame_processing=True,
|
||||
push_stop_frames=True,
|
||||
sample_rate=sample_rate,
|
||||
voice=voice_id,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
@@ -497,7 +496,7 @@ class AsyncAIHttpTTSService(TTSService):
|
||||
params: Additional input parameters for voice customization.
|
||||
**kwargs: Additional arguments passed to the parent TTSService.
|
||||
"""
|
||||
super().__init__(sample_rate=sample_rate, voice=voice_id, **kwargs)
|
||||
super().__init__(sample_rate=sample_rate, **kwargs)
|
||||
|
||||
params = params or AsyncAIHttpTTSService.InputParams()
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ class AWSPollyTTSService(TTSService):
|
||||
params: Additional input parameters for voice customization.
|
||||
**kwargs: Additional arguments passed to parent TTSService class.
|
||||
"""
|
||||
super().__init__(sample_rate=sample_rate, voice=voice_id, **kwargs)
|
||||
super().__init__(sample_rate=sample_rate, **kwargs)
|
||||
|
||||
params = params or AWSPollyTTSService.InputParams()
|
||||
|
||||
|
||||
@@ -295,7 +295,6 @@ class AzureTTSService(WordTTSService, AzureBaseTTSService):
|
||||
push_stop_frames=True,
|
||||
pause_frame_processing=True,
|
||||
sample_rate=sample_rate,
|
||||
voice=voice,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
@@ -734,7 +733,7 @@ class AzureHttpTTSService(TTSService, AzureBaseTTSService):
|
||||
params: Voice and synthesis parameters configuration.
|
||||
**kwargs: Additional arguments passed to parent TTSService.
|
||||
"""
|
||||
super().__init__(sample_rate=sample_rate, voice=voice, **kwargs)
|
||||
super().__init__(sample_rate=sample_rate, **kwargs)
|
||||
|
||||
# Initialize Azure-specific functionality from mixin
|
||||
self._init_azure_base(api_key=api_key, region=region, voice=voice, params=params)
|
||||
|
||||
@@ -213,7 +213,7 @@ class CambTTSService(TTSService):
|
||||
params: Additional voice parameters. If None, uses defaults.
|
||||
**kwargs: Additional arguments passed to parent TTSService.
|
||||
"""
|
||||
super().__init__(sample_rate=sample_rate, voice=voice_id, **kwargs)
|
||||
super().__init__(sample_rate=sample_rate, **kwargs)
|
||||
|
||||
self._api_key = api_key
|
||||
self._timeout = timeout
|
||||
|
||||
@@ -313,7 +313,6 @@ class CartesiaTTSService(AudioContextWordTTSService):
|
||||
pause_frame_processing=True,
|
||||
sample_rate=sample_rate,
|
||||
text_aggregator=text_aggregator,
|
||||
voice=voice_id,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
@@ -721,7 +720,7 @@ class CartesiaHttpTTSService(TTSService):
|
||||
params: Additional input parameters for voice customization.
|
||||
**kwargs: Additional arguments passed to the parent TTSService.
|
||||
"""
|
||||
super().__init__(sample_rate=sample_rate, voice=voice_id, **kwargs)
|
||||
super().__init__(sample_rate=sample_rate, **kwargs)
|
||||
|
||||
params = params or CartesiaHttpTTSService.InputParams()
|
||||
|
||||
|
||||
@@ -101,7 +101,6 @@ class DeepgramTTSService(WebsocketTTSService):
|
||||
pause_frame_processing=True,
|
||||
push_stop_frames=True,
|
||||
append_trailing_space=True,
|
||||
voice=voice,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
@@ -388,7 +387,7 @@ class DeepgramHttpTTSService(TTSService):
|
||||
encoding: Audio encoding format. Defaults to "linear16".
|
||||
**kwargs: Additional arguments passed to parent TTSService class.
|
||||
"""
|
||||
super().__init__(sample_rate=sample_rate, voice=voice, **kwargs)
|
||||
super().__init__(sample_rate=sample_rate, **kwargs)
|
||||
|
||||
self._api_key = api_key
|
||||
self._session = aiohttp_session
|
||||
|
||||
@@ -400,7 +400,6 @@ class ElevenLabsTTSService(AudioContextWordTTSService):
|
||||
push_stop_frames=True,
|
||||
pause_frame_processing=True,
|
||||
sample_rate=sample_rate,
|
||||
voice=voice_id,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
@@ -906,7 +905,6 @@ class ElevenLabsHttpTTSService(WordTTSService):
|
||||
push_text_frames=False,
|
||||
push_stop_frames=True,
|
||||
sample_rate=sample_rate,
|
||||
voice=voice_id,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
|
||||
@@ -602,7 +602,7 @@ class GoogleHttpTTSService(TTSService):
|
||||
params: Voice customization parameters including pitch, rate, volume, etc.
|
||||
**kwargs: Additional arguments passed to parent TTSService.
|
||||
"""
|
||||
super().__init__(sample_rate=sample_rate, voice=voice_id, **kwargs)
|
||||
super().__init__(sample_rate=sample_rate, **kwargs)
|
||||
|
||||
params = params or GoogleHttpTTSService.InputParams()
|
||||
|
||||
@@ -1015,7 +1015,7 @@ class GoogleTTSService(GoogleBaseTTSService):
|
||||
params: Language configuration parameters.
|
||||
**kwargs: Additional arguments passed to parent TTSService.
|
||||
"""
|
||||
super().__init__(sample_rate=sample_rate, voice=voice_id, **kwargs)
|
||||
super().__init__(sample_rate=sample_rate, **kwargs)
|
||||
|
||||
params = params or GoogleTTSService.InputParams()
|
||||
|
||||
@@ -1220,7 +1220,7 @@ class GeminiTTSService(GoogleBaseTTSService):
|
||||
f"Google TTS only supports {self.GOOGLE_SAMPLE_RATE}Hz sample rate. "
|
||||
f"Current rate of {sample_rate}Hz may cause issues."
|
||||
)
|
||||
super().__init__(sample_rate=sample_rate, voice=voice_id, **kwargs)
|
||||
super().__init__(sample_rate=sample_rate, **kwargs)
|
||||
|
||||
params = params or GeminiTTSService.InputParams()
|
||||
|
||||
|
||||
@@ -91,7 +91,6 @@ class GradiumTTSService(InterruptibleWordTTSService):
|
||||
push_stop_frames=True,
|
||||
pause_frame_processing=True,
|
||||
sample_rate=SAMPLE_RATE,
|
||||
voice=voice_id,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
|
||||
@@ -102,7 +102,6 @@ class GroqTTSService(TTSService):
|
||||
super().__init__(
|
||||
pause_frame_processing=True,
|
||||
sample_rate=sample_rate,
|
||||
voice=voice_id,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
|
||||
@@ -109,7 +109,6 @@ class HathoraTTSService(TTSService):
|
||||
"""
|
||||
super().__init__(
|
||||
sample_rate=sample_rate,
|
||||
voice=voice_id,
|
||||
**kwargs,
|
||||
)
|
||||
self._model = model
|
||||
|
||||
@@ -126,7 +126,6 @@ class HumeTTSService(WordTTSService):
|
||||
sample_rate=sample_rate,
|
||||
push_text_frames=False,
|
||||
push_stop_frames=True,
|
||||
voice=voice_id,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
|
||||
@@ -144,7 +144,6 @@ class InworldHttpTTSService(WordTTSService):
|
||||
push_text_frames=False,
|
||||
push_stop_frames=True,
|
||||
sample_rate=sample_rate,
|
||||
voice=voice_id,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
@@ -519,7 +518,6 @@ class InworldTTSService(AudioContextWordTTSService):
|
||||
sample_rate=sample_rate,
|
||||
aggregate_sentences=aggregate_sentences,
|
||||
append_trailing_space=append_trailing_space,
|
||||
voice=voice_id,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ class KokoroTTSService(TTSService):
|
||||
**kwargs: Additional arguments passed to parent `TTSService`.
|
||||
|
||||
"""
|
||||
super().__init__(voice=voice_id, **kwargs)
|
||||
super().__init__(**kwargs)
|
||||
|
||||
params = params or KokoroTTSService.InputParams()
|
||||
|
||||
|
||||
@@ -118,7 +118,6 @@ class LmntTTSService(InterruptibleTTSService):
|
||||
push_stop_frames=True,
|
||||
pause_frame_processing=True,
|
||||
sample_rate=sample_rate,
|
||||
voice=voice_id,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ class MiniMaxHttpTTSService(TTSService):
|
||||
params: Additional configuration parameters.
|
||||
**kwargs: Additional arguments passed to parent TTSService.
|
||||
"""
|
||||
super().__init__(sample_rate=sample_rate, voice=voice_id, **kwargs)
|
||||
super().__init__(sample_rate=sample_rate, **kwargs)
|
||||
|
||||
params = params or MiniMaxHttpTTSService.InputParams()
|
||||
|
||||
|
||||
@@ -139,7 +139,6 @@ class NeuphonicTTSService(InterruptibleTTSService):
|
||||
push_stop_frames=True,
|
||||
stop_frame_timeout_s=2.0,
|
||||
sample_rate=sample_rate,
|
||||
voice=voice_id,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
@@ -443,7 +442,7 @@ class NeuphonicHttpTTSService(TTSService):
|
||||
params: Additional input parameters for TTS configuration.
|
||||
**kwargs: Additional arguments passed to parent TTSService.
|
||||
"""
|
||||
super().__init__(sample_rate=sample_rate, voice=voice_id, **kwargs)
|
||||
super().__init__(sample_rate=sample_rate, **kwargs)
|
||||
|
||||
params = params or NeuphonicHttpTTSService.InputParams()
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ class OpenAITTSService(TTSService):
|
||||
f"OpenAI TTS only supports {self.OPENAI_SAMPLE_RATE}Hz sample rate. "
|
||||
f"Current rate of {sample_rate}Hz may cause issues."
|
||||
)
|
||||
super().__init__(sample_rate=sample_rate, voice=voice, **kwargs)
|
||||
super().__init__(sample_rate=sample_rate, **kwargs)
|
||||
|
||||
self.set_model_name(model)
|
||||
self._client = AsyncOpenAI(api_key=api_key, base_url=base_url)
|
||||
|
||||
@@ -173,7 +173,6 @@ class PlayHTTTSService(InterruptibleTTSService):
|
||||
super().__init__(
|
||||
pause_frame_processing=True,
|
||||
sample_rate=sample_rate,
|
||||
voice=voice_url,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
@@ -511,7 +510,7 @@ class PlayHTHttpTTSService(TTSService):
|
||||
params: Additional input parameters for voice customization.
|
||||
**kwargs: Additional arguments passed to parent TTSService.
|
||||
"""
|
||||
super().__init__(sample_rate=sample_rate, voice=voice_url, **kwargs)
|
||||
super().__init__(sample_rate=sample_rate, **kwargs)
|
||||
|
||||
# Warn about deprecated protocol parameter if explicitly provided
|
||||
if protocol:
|
||||
|
||||
@@ -94,7 +94,6 @@ class ResembleAITTSService(AudioContextWordTTSService):
|
||||
"""
|
||||
super().__init__(
|
||||
sample_rate=sample_rate,
|
||||
voice=voice_id,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
|
||||
@@ -191,7 +191,6 @@ class RimeTTSService(AudioContextWordTTSService):
|
||||
pause_frame_processing=True,
|
||||
append_trailing_space=True,
|
||||
sample_rate=sample_rate,
|
||||
voice=voice_id,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
@@ -582,7 +581,7 @@ class RimeHttpTTSService(TTSService):
|
||||
params: Additional configuration parameters.
|
||||
**kwargs: Additional arguments passed to parent TTSService.
|
||||
"""
|
||||
super().__init__(sample_rate=sample_rate, voice=voice_id, **kwargs)
|
||||
super().__init__(sample_rate=sample_rate, **kwargs)
|
||||
|
||||
params = params or RimeHttpTTSService.InputParams()
|
||||
|
||||
@@ -762,7 +761,6 @@ class RimeNonJsonTTSService(InterruptibleTTSService):
|
||||
aggregate_sentences=aggregate_sentences,
|
||||
push_stop_frames=True,
|
||||
pause_frame_processing=True,
|
||||
voice=voice_id,
|
||||
**kwargs,
|
||||
)
|
||||
params = params or RimeNonJsonTTSService.InputParams()
|
||||
|
||||
@@ -464,7 +464,7 @@ class SarvamHttpTTSService(TTSService):
|
||||
if voice_id is None:
|
||||
voice_id = self._config.default_speaker
|
||||
|
||||
super().__init__(sample_rate=sample_rate, voice=voice_id, **kwargs)
|
||||
super().__init__(sample_rate=sample_rate, **kwargs)
|
||||
|
||||
self._api_key = api_key
|
||||
self._base_url = base_url
|
||||
@@ -821,7 +821,6 @@ class SarvamTTSService(InterruptibleTTSService):
|
||||
pause_frame_processing=True,
|
||||
push_stop_frames=True,
|
||||
sample_rate=sample_rate,
|
||||
voice=voice_id,
|
||||
**kwargs,
|
||||
)
|
||||
params = params or SarvamTTSService.InputParams()
|
||||
|
||||
@@ -145,11 +145,6 @@ class TTSService(AIService):
|
||||
text_filter: Optional[BaseTextFilter] = None,
|
||||
# Audio transport destination of the generated frames.
|
||||
transport_destination: Optional[str] = None,
|
||||
# Voice identifier or name to use for speech synthesis
|
||||
voice: Optional[str] = None,
|
||||
# Language to use for speech synthesis. This will be translated to a
|
||||
# service-specific language identifier before being applied
|
||||
language: Optional[Language] = None,
|
||||
**kwargs,
|
||||
):
|
||||
"""Initialize the TTS service.
|
||||
@@ -183,10 +178,6 @@ class TTSService(AIService):
|
||||
Use `text_filters` instead, which allows multiple filters.
|
||||
|
||||
transport_destination: Destination for generated audio frames.
|
||||
voice: Voice identifier or name to use for speech synthesis.
|
||||
language: Language to use for speech synthesis. This will be
|
||||
translated to a service-specific language identifier before
|
||||
being applied.
|
||||
**kwargs: Additional arguments passed to the parent AIService.
|
||||
"""
|
||||
super().__init__(**kwargs)
|
||||
@@ -201,7 +192,7 @@ class TTSService(AIService):
|
||||
self._init_sample_rate = sample_rate
|
||||
self._sample_rate = 0
|
||||
self._settings = TTSSettings(
|
||||
voice=voice, language=language
|
||||
voice=""
|
||||
) # Here in case subclass doesn't implement more specific settings (hopefully shouldn't happen)
|
||||
self._text_aggregator: BaseTextAggregator = text_aggregator or SimpleTextAggregator()
|
||||
if text_aggregator:
|
||||
|
||||
@@ -111,7 +111,7 @@ class XTTSService(TTSService):
|
||||
sample_rate: Audio sample rate. If None, uses default.
|
||||
**kwargs: Additional arguments passed to parent TTSService.
|
||||
"""
|
||||
super().__init__(sample_rate=sample_rate, voice=voice_id, **kwargs)
|
||||
super().__init__(sample_rate=sample_rate, **kwargs)
|
||||
|
||||
self._settings = XTTSTTSSettings(
|
||||
voice=voice_id,
|
||||
|
||||
Reference in New Issue
Block a user