tts: don't connect to websocket if already connected
This commit is contained in:
@@ -194,6 +194,8 @@ class CartesiaTTSService(AudioContextWordTTSService):
|
|||||||
|
|
||||||
async def _connect_websocket(self):
|
async def _connect_websocket(self):
|
||||||
try:
|
try:
|
||||||
|
if self._websocket:
|
||||||
|
return
|
||||||
logger.debug("Connecting to Cartesia")
|
logger.debug("Connecting to Cartesia")
|
||||||
self._websocket = await websockets.connect(
|
self._websocket = await websockets.connect(
|
||||||
f"{self._url}?api_key={self._api_key}&cartesia_version={self._cartesia_version}"
|
f"{self._url}?api_key={self._api_key}&cartesia_version={self._cartesia_version}"
|
||||||
|
|||||||
@@ -308,6 +308,9 @@ class ElevenLabsTTSService(InterruptibleWordTTSService):
|
|||||||
|
|
||||||
async def _connect_websocket(self):
|
async def _connect_websocket(self):
|
||||||
try:
|
try:
|
||||||
|
if self._websocket:
|
||||||
|
return
|
||||||
|
|
||||||
logger.debug("Connecting to ElevenLabs")
|
logger.debug("Connecting to ElevenLabs")
|
||||||
|
|
||||||
voice_id = self._voice_id
|
voice_id = self._voice_id
|
||||||
|
|||||||
@@ -118,6 +118,9 @@ class FishAudioTTSService(InterruptibleTTSService):
|
|||||||
|
|
||||||
async def _connect_websocket(self):
|
async def _connect_websocket(self):
|
||||||
try:
|
try:
|
||||||
|
if self._websocket:
|
||||||
|
return
|
||||||
|
|
||||||
logger.debug("Connecting to Fish Audio")
|
logger.debug("Connecting to Fish Audio")
|
||||||
headers = {"Authorization": f"Bearer {self._api_key}"}
|
headers = {"Authorization": f"Bearer {self._api_key}"}
|
||||||
self._websocket = await websockets.connect(self._base_url, extra_headers=headers)
|
self._websocket = await websockets.connect(self._base_url, extra_headers=headers)
|
||||||
|
|||||||
@@ -124,6 +124,9 @@ class LmntTTSService(InterruptibleTTSService):
|
|||||||
async def _connect_websocket(self):
|
async def _connect_websocket(self):
|
||||||
"""Connect to LMNT websocket."""
|
"""Connect to LMNT websocket."""
|
||||||
try:
|
try:
|
||||||
|
if self._websocket:
|
||||||
|
return
|
||||||
|
|
||||||
logger.debug("Connecting to LMNT")
|
logger.debug("Connecting to LMNT")
|
||||||
|
|
||||||
# Build initial connection message
|
# Build initial connection message
|
||||||
|
|||||||
@@ -171,6 +171,9 @@ class PlayHTTTSService(InterruptibleTTSService):
|
|||||||
|
|
||||||
async def _connect_websocket(self):
|
async def _connect_websocket(self):
|
||||||
try:
|
try:
|
||||||
|
if self._websocket:
|
||||||
|
return
|
||||||
|
|
||||||
logger.debug("Connecting to PlayHT")
|
logger.debug("Connecting to PlayHT")
|
||||||
|
|
||||||
if not self._websocket_url:
|
if not self._websocket_url:
|
||||||
|
|||||||
@@ -180,6 +180,9 @@ class RimeTTSService(AudioContextWordTTSService):
|
|||||||
async def _connect_websocket(self):
|
async def _connect_websocket(self):
|
||||||
"""Connect to Rime websocket API with configured settings."""
|
"""Connect to Rime websocket API with configured settings."""
|
||||||
try:
|
try:
|
||||||
|
if self._websocket:
|
||||||
|
return
|
||||||
|
|
||||||
params = "&".join(f"{k}={v}" for k, v in self._settings.items())
|
params = "&".join(f"{k}={v}" for k, v in self._settings.items())
|
||||||
url = f"{self._url}?{params}"
|
url = f"{self._url}?{params}"
|
||||||
headers = {"Authorization": f"Bearer {self._api_key}"}
|
headers = {"Authorization": f"Bearer {self._api_key}"}
|
||||||
|
|||||||
Reference in New Issue
Block a user