Skip to content

Commit d882c0a

Browse files
committed
fix and debug
1 parent 7f955b3 commit d882c0a

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

src/elevenlabs/conversational_ai/conversation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from ..base_client import BaseElevenLabs
1515
from ..version import __version__
16-
from .base_connection import ConnectionType
16+
from .base_connection import ConnectionType, BaseConnection
1717
from .connection_factory import create_connection, determine_connection_type
1818

1919

@@ -340,7 +340,7 @@ def __init__(
340340

341341
self._conversation_id = None
342342
self._last_interrupt_id = 0
343-
self._connection = None
343+
self._connection: Optional[BaseConnection] = None
344344

345345
def _get_wss_url(self):
346346
base_http_url = self.client._client_wrapper.get_base_url()

src/elevenlabs/conversational_ai/webrtc_connection.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,19 @@ async def connect(self) -> None:
106106
# Enable microphone
107107
try:
108108
await self._room.local_participant.set_microphone_enabled(True)
109+
except AttributeError:
110+
try:
111+
await self._room.local_participant.enable_microphone()
112+
except AttributeError:
113+
self.debug({
114+
"type": "microphone_enable_error",
115+
"error": "Neither set_microphone_enabled nor enable_microphone methods available"
116+
})
109117
except Exception as e:
110118
self.debug({
111119
"type": "microphone_enable_error",
112120
"error": str(e)
113121
})
114-
# Don't fail the connection for microphone issues
115122

116123
# Send overrides if any
117124
if self.overrides:
@@ -319,7 +326,26 @@ async def set_microphone_enabled(self, enabled: bool) -> None:
319326
if not self._room or not self._room.local_participant:
320327
raise RuntimeError("Room not connected")
321328

322-
await self._room.local_participant.set_microphone_enabled(enabled)
329+
try:
330+
await self._room.local_participant.set_microphone_enabled(enabled)
331+
except AttributeError:
332+
try:
333+
if enabled:
334+
await self._room.local_participant.enable_microphone()
335+
else:
336+
await self._room.local_participant.disable_microphone()
337+
except AttributeError:
338+
self.debug({
339+
"type": "microphone_control_error",
340+
"enabled": enabled,
341+
"error": "Microphone control methods not available"
342+
})
343+
except Exception as e:
344+
self.debug({
345+
"type": "microphone_control_error",
346+
"enabled": enabled,
347+
"error": str(e)
348+
})
323349

324350
async def set_microphone_device(self, device_id: str) -> None:
325351
"""Set the microphone input device."""

0 commit comments

Comments
 (0)