Update Lmnt TTS to support updating settings dynamically

This commit is contained in:
Paul Kompfner
2026-02-18 14:47:38 -05:00
parent 416e1cf877
commit 0c73b77327
2 changed files with 20 additions and 3 deletions

View File

@@ -100,8 +100,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
await task.queue_frames([LLMRunFrame()])
await asyncio.sleep(10)
logger.info('Updating LMNT TTS settings: voice="lily"')
await task.queue_frame(TTSUpdateSettingsFrame(update=LmntTTSSettings(voice="lily")))
logger.info('Updating LMNT TTS settings: voice="tyler"')
await task.queue_frame(TTSUpdateSettingsFrame(update=LmntTTSSettings(voice="tyler")))
@transport.event_handler("on_client_disconnected")
async def on_client_disconnected(transport, client):

View File

@@ -8,7 +8,7 @@
import json
from dataclasses import dataclass, field
from typing import AsyncGenerator, Optional
from typing import Any, AsyncGenerator, Optional
from loguru import logger
@@ -207,6 +207,23 @@ class LmntTTSService(InterruptibleTTSService):
await self._disconnect_websocket()
async def _update_settings(self, update: TTSSettings) -> dict[str, Any]:
"""Apply a settings update.
Args:
update: A :class:`TTSSettings` (or ``LmntTTSSettings``) delta.
Returns:
Dict mapping changed field names to their previous values.
"""
changed = await super()._update_settings(update)
if changed:
await self._disconnect()
await self._connect()
return changed
async def _connect_websocket(self):
"""Connect to LMNT websocket."""
try: