diff --git a/CHANGELOG.md b/CHANGELOG.md index 3868effb6..7ebc30c20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 A video service that handles audio streaming and requests HeyGen to generate avatar video responses. (see https://www.heygen.com/) +- Added the ability to switch voices to `RimeTTSService`. + - Added Async.ai TTS integration (https://async.ai/) + - `AsyncAITTSService` – WebSocket-based streaming TTS with interruption support - `AsyncAIHttpTTSService` – HTTP-based streaming TTS service - Example scripts: diff --git a/src/pipecat/services/rime/tts.py b/src/pipecat/services/rime/tts.py index a4f0ffda6..e18df2742 100644 --- a/src/pipecat/services/rime/tts.py +++ b/src/pipecat/services/rime/tts.py @@ -13,7 +13,7 @@ using Rime's API for streaming and batch audio synthesis. import base64 import json import uuid -from typing import AsyncGenerator, Optional +from typing import Any, AsyncGenerator, Mapping, Optional import aiohttp from loguru import logger @@ -181,6 +181,16 @@ class RimeTTSService(AudioContextWordTTSService): self._model = model await super().set_model(model) + async def _update_settings(self, settings: Mapping[str, Any]): + """Update service settings and reconnect if voice changed.""" + prev_voice = self._voice_id + await super()._update_settings(settings) + if not prev_voice == self._voice_id: + self._settings["speaker"] = self._voice_id + logger.info(f"Switching TTS voice to: [{self._voice_id}]") + await self._disconnect() + await self._connect() + def _build_msg(self, text: str = "") -> dict: """Build JSON message for Rime API.""" return {"text": text, "contextId": self._context_id}