From 3061cfd9dfa0cf2be6493d218c3a4c5acc30231e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 30 Nov 2023 22:12:41 -0800 Subject: [PATCH] Adding mulaw streaming support to ElevenLabs --- playground/streaming/synthesizer/synthesize.py | 3 +++ vocode/streaming/synthesizer/eleven_labs_synthesizer.py | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/playground/streaming/synthesizer/synthesize.py b/playground/streaming/synthesizer/synthesize.py index c3901cd7c..a0b5ac2ea 100644 --- a/playground/streaming/synthesizer/synthesize.py +++ b/playground/streaming/synthesizer/synthesize.py @@ -148,6 +148,9 @@ async def main(): synthesizer = ElevenLabsSynthesizer( synthesizer_config=ElevenLabsSynthesizerConfig( experimental_streaming=False, + stability=0.0, + similarity_boost=0.0, + model_id="nova", optimize_streaming_latency=0, sampling_rate=8000, audio_encoding=AudioEncoding.MULAW, diff --git a/vocode/streaming/synthesizer/eleven_labs_synthesizer.py b/vocode/streaming/synthesizer/eleven_labs_synthesizer.py index 22c96fa46..d7933e6dc 100644 --- a/vocode/streaming/synthesizer/eleven_labs_synthesizer.py +++ b/vocode/streaming/synthesizer/eleven_labs_synthesizer.py @@ -100,8 +100,6 @@ async def create_speech( base_url = urljoin(ELEVEN_LABS_BASE_URL, f"text-to-speech/{self.voice_id}") - print(base_url) - if self.experimental_streaming: base_url = urljoin(base_url + "/", "stream") @@ -195,6 +193,10 @@ async def create_speech( message, seconds, self.words_per_minute ), ) + else: + raise RuntimeError( + f"Unsupported ElevenLabs configuration: {self.synthesizer_config.sampling_rate}, {self.synthesizer_config.audio_encoding}, {self.output_format}" + ) def _get_eleven_labs_format(self): sampling_rate = self.synthesizer_config.sampling_rate