fix: ElevenLabsTTSService voice settings not being sent
This commit is contained in:
@@ -35,6 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed an issue where voice settings weren't applied to ElevenLabsTTSService.
|
||||||
|
|
||||||
- Fixed an issue with `GroqTTSService` where it was not properly parsing the
|
- Fixed an issue with `GroqTTSService` where it was not properly parsing the
|
||||||
WAV file header.
|
WAV file header.
|
||||||
|
|
||||||
|
|||||||
@@ -428,26 +428,9 @@ class ElevenLabsTTSService(AudioContextWordTTSService):
|
|||||||
break
|
break
|
||||||
|
|
||||||
async def _send_text(self, text: str):
|
async def _send_text(self, text: str):
|
||||||
if self._websocket:
|
if self._websocket and self._context_id:
|
||||||
if not self._context_id:
|
msg = {"text": text, "context_id": self._context_id}
|
||||||
# First message for a new context - need a space to initialize
|
await self._websocket.send(json.dumps(msg))
|
||||||
msg = {"text": " ", "context_id": str(uuid.uuid4())}
|
|
||||||
|
|
||||||
# Add voice settings only in first message for a context
|
|
||||||
if self._voice_settings:
|
|
||||||
msg["voice_settings"] = self._voice_settings
|
|
||||||
|
|
||||||
await self._websocket.send(json.dumps(msg))
|
|
||||||
self._context_id = msg["context_id"]
|
|
||||||
logger.trace(f"Created new context {self._context_id}")
|
|
||||||
|
|
||||||
# Now send the actual text content
|
|
||||||
msg = {"text": text, "context_id": self._context_id}
|
|
||||||
await self._websocket.send(json.dumps(msg))
|
|
||||||
else:
|
|
||||||
# Continuing with an existing context
|
|
||||||
msg = {"text": text, "context_id": self._context_id}
|
|
||||||
await self._websocket.send(json.dumps(msg))
|
|
||||||
|
|
||||||
@traced_tts
|
@traced_tts
|
||||||
async def run_tts(self, text: str) -> AsyncGenerator[Frame, None]:
|
async def run_tts(self, text: str) -> AsyncGenerator[Frame, None]:
|
||||||
@@ -475,8 +458,17 @@ class ElevenLabsTTSService(AudioContextWordTTSService):
|
|||||||
self._context_id = str(uuid.uuid4())
|
self._context_id = str(uuid.uuid4())
|
||||||
await self.create_audio_context(self._context_id)
|
await self.create_audio_context(self._context_id)
|
||||||
|
|
||||||
await self._send_text(text)
|
# Initialize context with voice settings
|
||||||
await self.start_tts_usage_metrics(text)
|
msg = {"text": " ", "context_id": self._context_id}
|
||||||
|
if self._voice_settings:
|
||||||
|
msg["voice_settings"] = self._voice_settings
|
||||||
|
await self._websocket.send(json.dumps(msg))
|
||||||
|
logger.trace(f"Created new context {self._context_id} with voice settings")
|
||||||
|
|
||||||
|
await self._send_text(text)
|
||||||
|
await self.start_tts_usage_metrics(text)
|
||||||
|
else:
|
||||||
|
await self._send_text(text)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"{self} error sending message: {e}")
|
logger.error(f"{self} error sending message: {e}")
|
||||||
yield TTSStoppedFrame()
|
yield TTSStoppedFrame()
|
||||||
|
|||||||
Reference in New Issue
Block a user