forked from vocodedev/vocode-core
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/ajar98/vocode-python into a…
…dd-cartesia-tts
- Loading branch information
Showing
2 changed files
with
14 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +0,0 @@ | ||
from typing import Type | ||
from vocode.streaming.models.synthesizer import ( | ||
AzureSynthesizerConfig, | ||
CartesiaSynthesizerConfig, | ||
ElevenLabsSynthesizerConfig, | ||
PlayHtSynthesizerConfig, | ||
RimeSynthesizerConfig, | ||
StreamElementsSynthesizerConfig, | ||
SynthesizerConfig, | ||
) | ||
from vocode.streaming.synthesizer.abstract_factory import AbstractSynthesizerFactory | ||
from vocode.streaming.synthesizer.azure_synthesizer import AzureSynthesizer | ||
from vocode.streaming.synthesizer.base_synthesizer import BaseSynthesizer | ||
from vocode.streaming.synthesizer.cartesia_synthesizer import CartesiaSynthesizer | ||
from vocode.streaming.synthesizer.eleven_labs_synthesizer import ElevenLabsSynthesizer | ||
from vocode.streaming.synthesizer.eleven_labs_websocket_synthesizer import ElevenLabsWSSynthesizer | ||
from vocode.streaming.synthesizer.play_ht_synthesizer import PlayHtSynthesizer | ||
from vocode.streaming.synthesizer.play_ht_synthesizer_v2 import PlayHtSynthesizerV2 | ||
from vocode.streaming.synthesizer.rime_synthesizer import RimeSynthesizer | ||
from vocode.streaming.synthesizer.stream_elements_synthesizer import StreamElementsSynthesizer | ||
|
||
|
||
class DefaultSynthesizerFactory(AbstractSynthesizerFactory): | ||
def create_synthesizer( | ||
self, | ||
synthesizer_config: SynthesizerConfig, | ||
): | ||
if isinstance(synthesizer_config, AzureSynthesizerConfig): | ||
return AzureSynthesizer(synthesizer_config) | ||
elif isinstance(synthesizer_config, CartesiaSynthesizerConfig): | ||
return CartesiaSynthesizer(synthesizer_config) | ||
elif isinstance(synthesizer_config, ElevenLabsSynthesizerConfig): | ||
eleven_labs_synthesizer_class_type: Type[BaseSynthesizer] = ElevenLabsSynthesizer | ||
if synthesizer_config.experimental_websocket: | ||
eleven_labs_synthesizer_class_type = ElevenLabsWSSynthesizer | ||
return eleven_labs_synthesizer_class_type(synthesizer_config) | ||
elif isinstance(synthesizer_config, PlayHtSynthesizerConfig): | ||
if synthesizer_config.version == "2": | ||
return PlayHtSynthesizerV2(synthesizer_config) | ||
else: | ||
return PlayHtSynthesizer(synthesizer_config) | ||
elif isinstance(synthesizer_config, RimeSynthesizerConfig): | ||
return RimeSynthesizer(synthesizer_config) | ||
elif isinstance(synthesizer_config, StreamElementsSynthesizerConfig): | ||
return StreamElementsSynthesizer(synthesizer_config) | ||
else: | ||
raise Exception("Invalid synthesizer config") | ||