This commit is contained in:
Manasseh 2026-06-09 11:31:56 -04:00 committed by GitHub
commit 93cced54d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 133 additions and 4 deletions

View file

@ -0,0 +1,23 @@
"""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()

View file

@ -7,6 +7,7 @@ from loguru import logger
from api.constants import MPS_API_URL
from api.services.configuration.registry import ServiceProviders
from api.services.pipecat.inworld_tts import InworldOwnedSessionTTSService
from api.services.pipecat.minimax_tts import MiniMaxOwnedSessionTTSService
from api.utils.url_security import validate_user_configured_service_url
from pipecat.services.assemblyai.stt import AssemblyAISTTService, AssemblyAISTTSettings
@ -38,6 +39,7 @@ from pipecat.services.google.vertex.llm import (
GoogleVertexLLMService,
GoogleVertexLLMSettings,
)
from pipecat.services.inworld.tts import InworldTTSSettings
from pipecat.services.groq.llm import GroqLLMService, GroqLLMSettings
from pipecat.services.minimax.llm import MiniMaxLLMService
from pipecat.services.minimax.tts import MiniMaxTTSSettings
@ -398,6 +400,28 @@ def create_tts_service(user_config, audio_config: "AudioConfig"):
skip_aggregator_types=["recording_router", "recording"],
silence_time_s=1.0,
)
elif user_config.tts.provider == ServiceProviders.INWORLD.value:
voice = getattr(user_config.tts, "voice", None) or "Ashley"
model = getattr(user_config.tts, "model", None) or "inworld-tts-2"
speed = getattr(user_config.tts, "speed", None)
language = getattr(user_config.tts, "language", None) or "en-US"
delivery_mode = getattr(user_config.tts, "delivery_mode", None) or "BALANCED"
session = aiohttp.ClientSession()
return InworldOwnedSessionTTSService(
api_key=user_config.tts.api_key,
aiohttp_session=session,
streaming=True,
settings=InworldTTSSettings(
voice=voice,
model=model,
language=language,
speaking_rate=speed,
delivery_mode=delivery_mode,
),
text_filters=[xml_function_tag_filter],
skip_aggregator_types=["recording_router", "recording"],
silence_time_s=1.0,
)
elif user_config.tts.provider == ServiceProviders.DOGRAH.value:
# Convert HTTP URL to WebSocket URL for TTS
base_url = MPS_API_URL.replace("http://", "ws://").replace("https://", "wss://")