DailyParams: allow enabling/disabling camera/microphone tracks

This commit is contained in:
Aleix Conchillo Flaqué
2025-04-30 19:23:03 -07:00
parent 304153dd03
commit 8d915c5ccb
3 changed files with 16 additions and 2 deletions

View File

@@ -28,6 +28,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
each generated `TTSAudioRawFrame`. This allows sending multiple bots' audio to each generated `TTSAudioRawFrame`. This allows sending multiple bots' audio to
multiple destinations in the same pipeline. multiple destinations in the same pipeline.
- Added `DailyTransportParams.camera_enabled` and
`DailyTransportParams.microphone_enabled` which allows you to enable/disable
the main camera or microphone tracks. This is useful if you only want to use
custom tracks and not send the main tracks. Note that you still need
`audio_out_enabled=True` or `video_out_enabled`.
- Added `RTVIObserverParams` which allows you to configure what RTVI messages - Added `RTVIObserverParams` which allows you to configure what RTVI messages
are sent to the clients. are sent to the clients.

View File

@@ -57,6 +57,7 @@ async def main():
), ),
}, },
audio_out_destinations=["spanish", "french", "german"], audio_out_destinations=["spanish", "french", "german"],
microphone_enabled=False, # Disable since we just use custom tracks
vad_analyzer=SileroVADAnalyzer(), vad_analyzer=SileroVADAnalyzer(),
), ),
) )

View File

@@ -154,6 +154,8 @@ class DailyParams(TransportParams):
api_url: Daily API base URL api_url: Daily API base URL
api_key: Daily API authentication key api_key: Daily API authentication key
dialin_settings: Optional settings for dial-in functionality dialin_settings: Optional settings for dial-in functionality
camera_enabled: Whether to enable the main camera track
microphone_enabled: Whether to enable the main microphone track
transcription_enabled: Whether to enable speech transcription transcription_enabled: Whether to enable speech transcription
transcription_settings: Configuration for transcription service transcription_settings: Configuration for transcription service
""" """
@@ -161,6 +163,8 @@ class DailyParams(TransportParams):
api_url: str = "https://api.daily.co/v1" api_url: str = "https://api.daily.co/v1"
api_key: str = "" api_key: str = ""
dialin_settings: Optional[DailyDialinSettings] = None dialin_settings: Optional[DailyDialinSettings] = None
camera_enabled: bool = True
microphone_enabled: bool = True
transcription_enabled: bool = False transcription_enabled: bool = False
transcription_settings: DailyTranscriptionSettings = DailyTranscriptionSettings() transcription_settings: DailyTranscriptionSettings = DailyTranscriptionSettings()
@@ -502,6 +506,9 @@ class DailyTransportClient(EventHandler):
async def _join(self): async def _join(self):
future = self._get_event_loop().create_future() future = self._get_event_loop().create_future()
camera_enabled = self._params.video_out_enabled and self._params.camera_enabled
microphone_enabled = self._params.audio_out_enabled and self._params.microphone_enabled
self._client.join( self._client.join(
self._room_url, self._room_url,
self._token, self._token,
@@ -509,13 +516,13 @@ class DailyTransportClient(EventHandler):
client_settings={ client_settings={
"inputs": { "inputs": {
"camera": { "camera": {
"isEnabled": self._params.video_out_enabled, "isEnabled": camera_enabled,
"settings": { "settings": {
"deviceId": self._camera_name(), "deviceId": self._camera_name(),
}, },
}, },
"microphone": { "microphone": {
"isEnabled": self._params.audio_out_enabled, "isEnabled": microphone_enabled,
"settings": { "settings": {
"deviceId": self._mic_name(), "deviceId": self._mic_name(),
"customConstraints": { "customConstraints": {