mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-19 08:28:10 +02:00
23 lines
847 B
Python
23 lines
847 B
Python
"""Inworld TTS wrapper that closes its aiohttp session in cleanup().
|
|
|
|
Pipecat's InworldHttpTTSService leaves session disposal to the caller. Our
|
|
factory creates a fresh session per service instance, so we own its close here
|
|
to avoid leaking sockets/FDs on shutdown.
|
|
"""
|
|
|
|
import aiohttp
|
|
|
|
from pipecat.services.inworld.tts import InworldHttpTTSService
|
|
|
|
|
|
class InworldOwnedSessionTTSService(InworldHttpTTSService):
|
|
"""InworldHttpTTSService variant that owns its aiohttp session lifecycle."""
|
|
|
|
def __init__(self, *args, aiohttp_session: aiohttp.ClientSession, **kwargs):
|
|
super().__init__(*args, aiohttp_session=aiohttp_session, **kwargs)
|
|
self._owned_session = aiohttp_session
|
|
|
|
async def cleanup(self):
|
|
await super().cleanup()
|
|
if not self._owned_session.closed:
|
|
await self._owned_session.close()
|