mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-22 08:38:13 +02:00
chore: code refactor
This commit is contained in:
parent
c0cbc65de3
commit
c7812bf189
29 changed files with 538 additions and 800 deletions
|
|
@ -80,22 +80,14 @@ def register_event_handlers(
|
|||
@transport.event_handler("on_client_disconnected")
|
||||
async def on_client_disconnected(_transport, _participant):
|
||||
call_disposed = engine.is_call_disposed()
|
||||
transfer_in_progress = getattr(engine, '_transfer_in_progress', False)
|
||||
|
||||
|
||||
logger.debug(
|
||||
f"In on_client_disconnected callback handler. Call disposed: {call_disposed}, "
|
||||
f"Transfer in progress: {transfer_in_progress}"
|
||||
f"In on_client_disconnected callback handler. Call disposed: {call_disposed}"
|
||||
)
|
||||
|
||||
# Stop recordings
|
||||
await audio_buffer.stop_recording()
|
||||
|
||||
# Skip auto hang-up if transfer is in progress
|
||||
if transfer_in_progress:
|
||||
logger.info("Transfer in progress - skipping auto hang-up, letting redirect handle call")
|
||||
return
|
||||
logger.info("Transfer in progress - False, proceeding with hang up")
|
||||
|
||||
await engine.end_call_with_reason(
|
||||
EndTaskReason.USER_HANGUP.value, abort_immediately=True
|
||||
)
|
||||
|
|
|
|||
|
|
@ -73,8 +73,7 @@ def build_pipeline(
|
|||
pipeline_engine_callback_processor,
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
|
||||
processors.extend(
|
||||
[
|
||||
tts, # TTS
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ async def run_pipeline_twilio(
|
|||
workflow.organization_id,
|
||||
vad_config,
|
||||
ambient_noise_config,
|
||||
)
|
||||
)
|
||||
await _run_pipeline(
|
||||
transport,
|
||||
workflow_id,
|
||||
|
|
@ -556,8 +556,9 @@ async def _run_pipeline(
|
|||
# Create pipeline components
|
||||
audio_buffer, context = create_pipeline_components(audio_config)
|
||||
|
||||
# Set the context and audio_buffer after creation
|
||||
# Set the context, audio_config, and audio_buffer after creation
|
||||
engine.set_context(context)
|
||||
engine.set_audio_config(audio_config)
|
||||
|
||||
# Set Stasis connection for immediate transfers (if available)
|
||||
if stasis_connection:
|
||||
|
|
@ -638,6 +639,9 @@ async def _run_pipeline(
|
|||
|
||||
@user_context_aggregator.event_handler("on_user_turn_idle")
|
||||
async def on_user_turn_idle(aggregator):
|
||||
if engine._transferring_call:
|
||||
logger.debug("Not calling user idle since we are transferring call.")
|
||||
return
|
||||
await user_idle_handler.handle_idle(aggregator)
|
||||
|
||||
@user_context_aggregator.event_handler("on_user_turn_started")
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ from pipecat.transports.websocket.fastapi import (
|
|||
FastAPIWebsocketParams,
|
||||
FastAPIWebsocketTransport,
|
||||
)
|
||||
from loguru import logger
|
||||
|
||||
librnnoise_path = os.path.normpath(
|
||||
str(APP_ROOT_DIR / "native" / "rnnoise" / "librnnoise.so")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue