Merge pull request #722 from pipecat-ai/aleix/more-dailin-events

transports(daily): add more dial-in events
This commit is contained in:
Aleix Conchillo Flaqué
2024-11-17 01:09:01 +08:00
committed by GitHub
3 changed files with 42 additions and 1 deletions

View File

@@ -9,14 +9,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Added `DailyTransport` events `dialin-connected`, `dialin-stopped`,
`dialin-error` and `dialin-warning`. Needs daily-python >= 0.13.0.
- Added `RimeHttpTTSService` and the `07q-interruptible-rime.py` foundational - Added `RimeHttpTTSService` and the `07q-interruptible-rime.py` foundational
example. example.
- Added `STTMuteFilter`, a general-purpose processor that combines STT - Added `STTMuteFilter`, a general-purpose processor that combines STT
muting and interruption control. When active, it prevents both transcription muting and interruption control. When active, it prevents both transcription
and interruptions during bot speech. The processor supports multiple and interruptions during bot speech. The processor supports multiple
strategies: `FIRST_SPEECH` (mute only during bot's first strategies: `FIRST_SPEECH` (mute only during bot's first
speech), `ALWAYS` (mute during all bot speech), or `CUSTOM` (using provided speech), `ALWAYS` (mute during all bot speech), or `CUSTOM` (using provided
callback). callback).
- Added `STTMuteFrame`, a control frame that enables/disables speech - Added `STTMuteFrame`, a control frame that enables/disables speech
transcription in STT services. transcription in STT services.

View File

@@ -42,7 +42,7 @@ aws = [ "boto3~=1.35.27" ]
azure = [ "azure-cognitiveservices-speech~=1.40.0" ] azure = [ "azure-cognitiveservices-speech~=1.40.0" ]
canonical = [ "aiofiles~=24.1.0" ] canonical = [ "aiofiles~=24.1.0" ]
cartesia = [ "cartesia~=1.0.13", "websockets~=13.1" ] cartesia = [ "cartesia~=1.0.13", "websockets~=13.1" ]
daily = [ "daily-python~=0.12.0" ] daily = [ "daily-python~=0.13.0" ]
deepgram = [ "deepgram-sdk~=3.7.3" ] deepgram = [ "deepgram-sdk~=3.7.3" ]
elevenlabs = [ "websockets~=13.1" ] elevenlabs = [ "websockets~=13.1" ]
examples = [ "python-dotenv~=1.0.1", "flask~=3.0.3", "flask_cors~=4.0.1" ] examples = [ "python-dotenv~=1.0.1", "flask~=3.0.3", "flask_cors~=4.0.1" ]

View File

@@ -128,7 +128,11 @@ class DailyCallbacks(BaseModel):
on_error: Callable[[str], Awaitable[None]] on_error: Callable[[str], Awaitable[None]]
on_app_message: Callable[[Any, str], Awaitable[None]] on_app_message: Callable[[Any, str], Awaitable[None]]
on_call_state_updated: Callable[[str], Awaitable[None]] on_call_state_updated: Callable[[str], Awaitable[None]]
on_dialin_connected: Callable[[Any], Awaitable[None]]
on_dialin_ready: Callable[[str], Awaitable[None]] on_dialin_ready: Callable[[str], Awaitable[None]]
on_dialin_stopped: Callable[[Any], Awaitable[None]]
on_dialin_error: Callable[[Any], Awaitable[None]]
on_dialin_warning: Callable[[Any], Awaitable[None]]
on_dialout_answered: Callable[[Any], Awaitable[None]] on_dialout_answered: Callable[[Any], Awaitable[None]]
on_dialout_connected: Callable[[Any], Awaitable[None]] on_dialout_connected: Callable[[Any], Awaitable[None]]
on_dialout_stopped: Callable[[Any], Awaitable[None]] on_dialout_stopped: Callable[[Any], Awaitable[None]]
@@ -536,9 +540,21 @@ class DailyTransportClient(EventHandler):
def on_call_state_updated(self, state: str): def on_call_state_updated(self, state: str):
self._call_async_callback(self._callbacks.on_call_state_updated, state) self._call_async_callback(self._callbacks.on_call_state_updated, state)
def on_dialin_connected(self, data: Any):
self._call_async_callback(self._callbacks.on_dialin_connected, data)
def on_dialin_ready(self, sip_endpoint: str): def on_dialin_ready(self, sip_endpoint: str):
self._call_async_callback(self._callbacks.on_dialin_ready, sip_endpoint) self._call_async_callback(self._callbacks.on_dialin_ready, sip_endpoint)
def on_dialin_stopped(self, data: Any):
self._call_async_callback(self._callbacks.on_dialin_stopped, data)
def on_dialin_error(self, data: Any):
self._call_async_callback(self._callbacks.on_dialin_error, data)
def on_dialin_warning(self, data: Any):
self._call_async_callback(self._callbacks.on_dialin_warning, data)
def on_dialout_answered(self, data: Any): def on_dialout_answered(self, data: Any):
self._call_async_callback(self._callbacks.on_dialout_answered, data) self._call_async_callback(self._callbacks.on_dialout_answered, data)
@@ -822,7 +838,11 @@ class DailyTransport(BaseTransport):
on_error=self._on_error, on_error=self._on_error,
on_app_message=self._on_app_message, on_app_message=self._on_app_message,
on_call_state_updated=self._on_call_state_updated, on_call_state_updated=self._on_call_state_updated,
on_dialin_connected=self._on_dialin_connected,
on_dialin_ready=self._on_dialin_ready, on_dialin_ready=self._on_dialin_ready,
on_dialin_stopped=self._on_dialin_stopped,
on_dialin_error=self._on_dialin_error,
on_dialin_warning=self._on_dialin_warning,
on_dialout_answered=self._on_dialout_answered, on_dialout_answered=self._on_dialout_answered,
on_dialout_connected=self._on_dialout_connected, on_dialout_connected=self._on_dialout_connected,
on_dialout_stopped=self._on_dialout_stopped, on_dialout_stopped=self._on_dialout_stopped,
@@ -851,7 +871,11 @@ class DailyTransport(BaseTransport):
self._register_event_handler("on_left") self._register_event_handler("on_left")
self._register_event_handler("on_app_message") self._register_event_handler("on_app_message")
self._register_event_handler("on_call_state_updated") self._register_event_handler("on_call_state_updated")
self._register_event_handler("on_dialin_connected")
self._register_event_handler("on_dialin_ready") self._register_event_handler("on_dialin_ready")
self._register_event_handler("on_dialin_stopped")
self._register_event_handler("on_dialin_error")
self._register_event_handler("on_dialin_warning")
self._register_event_handler("on_dialout_answered") self._register_event_handler("on_dialout_answered")
self._register_event_handler("on_dialout_connected") self._register_event_handler("on_dialout_connected")
self._register_event_handler("on_dialout_stopped") self._register_event_handler("on_dialout_stopped")
@@ -987,11 +1011,23 @@ class DailyTransport(BaseTransport):
except Exception as e: except Exception as e:
logger.exception(f"Error handling dialin-ready event ({url}): {e}") logger.exception(f"Error handling dialin-ready event ({url}): {e}")
async def _on_dialin_connected(self, data):
await self._call_event_handler("on_dialin_connected", data)
async def _on_dialin_ready(self, sip_endpoint): async def _on_dialin_ready(self, sip_endpoint):
if self._params.dialin_settings: if self._params.dialin_settings:
await self._handle_dialin_ready(sip_endpoint) await self._handle_dialin_ready(sip_endpoint)
await self._call_event_handler("on_dialin_ready", sip_endpoint) await self._call_event_handler("on_dialin_ready", sip_endpoint)
async def _on_dialin_stopped(self, data):
await self._call_event_handler("on_dialin_stopped", data)
async def _on_dialin_error(self, data):
await self._call_event_handler("on_dialin_error", data)
async def _on_dialin_warning(self, data):
await self._call_event_handler("on_dialin_warning", data)
async def _on_dialout_answered(self, data): async def _on_dialout_answered(self, data):
await self._call_event_handler("on_dialout_answered", data) await self._call_event_handler("on_dialout_answered", data)