feat: Added Pre Recorded Audio Support For Daily#476
feat: Added Pre Recorded Audio Support For Daily#476manas-narra wants to merge 1 commit intojuspay:releasefrom
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
WalkthroughThe pull request introduces a daily-mode greeting preparation and playback flow for the Breeze Buddy agent. It retrieves lead and template data, prepares greeting audio frames from Redis, stores a TTS service reference, and orchestrates pipeline synchronization to push greeting frames after pipeline readiness during Daily startup. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Agent as Breeze Buddy Agent
participant Daily as Daily Service
participant Redis
participant Pipeline as Pipeline
participant TTS
Client->>Daily: start_daily_session(lead_id, merchant_id, shop_id)
Daily->>Daily: Retrieve lead by ID & validate
Daily->>Daily: Fetch template (if available)
Daily->>Redis: prepare_and_store_initial_greeting()
rect rgb(230, 245, 250)
Note over Redis: Store greeting audio (template/lead preference)
end
Daily->>Daily: Create Daily room & generate token
Daily->>Agent: Start bot with Daily transport
rect rgb(240, 255, 240)
Note over Agent: Greeting Playback Phase
end
Agent->>Agent: Initialize pipeline
Agent->>Pipeline: Register pipeline-started event handler
Pipeline-->>Agent: Signal pipeline ready
Agent->>Redis: prepare_daily_greeting_frame()
rect rgb(245, 240, 255)
Note over Redis: Retrieve & convert audio (8kHz mulaw → 16kHz PCM)
end
Redis-->>Agent: TTSAudioRawFrame + source
Agent->>Agent: Wait for pipeline readiness
Agent->>TTS: Push greeting frame
TTS-->>Client: Transmit greeting audio
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
app/ai/voice/agents/breeze_buddy/services/daily/daily.py (1)
78-103: Lead and template fetching duplicated between daily.py and agent.py.The lead is fetched here in
start_daily_session(line 79) and then again inagent.py(line 220) using the samelead_id. Similarly, the template is fetched here (lines 86-90) and again inagent.pyvia_load_template_config. This results in redundant database queries.Consider passing the fetched
leadandtemplateobjects to the bot viarunner_args.bodyinstead of just thelead_id, or document this as intentional if the separation of concerns is preferred.app/ai/voice/agents/breeze_buddy/agent.py (1)
575-595: Consider adding a timeout to the pipeline ready wait.The
await self._pipeline_started_event.wait()(line 580) could block indefinitely if the pipeline fails to start. Consider adding a timeout to prevent the handler from hanging:♻️ Suggested improvement
- # Wait for pipeline to be ready before pushing - await self._pipeline_started_event.wait() + # Wait for pipeline to be ready before pushing (with timeout) + try: + await asyncio.wait_for( + self._pipeline_started_event.wait(), + timeout=5.0 # 5 second timeout + ) + except asyncio.TimeoutError: + logger.warning("Pipeline start timeout - skipping greeting audio") + return
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
app/ai/voice/agents/breeze_buddy/agent.pyapp/ai/voice/agents/breeze_buddy/services/daily/daily.pyapp/ai/voice/agents/breeze_buddy/utils/common.py
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: badri-singhal
Repo: juspay/clairvoyance PR: 465
File: app/ai/voice/agents/breeze_buddy/agent.py:334-340
Timestamp: 2026-01-06T18:14:12.083Z
Learning: Initial greeting audio is now intentionally sent for both Twilio and Exotel providers in agent.py, where previously only Twilio received it.
📚 Learning: 2026-01-06T18:14:12.083Z
Learnt from: badri-singhal
Repo: juspay/clairvoyance PR: 465
File: app/ai/voice/agents/breeze_buddy/agent.py:334-340
Timestamp: 2026-01-06T18:14:12.083Z
Learning: Initial greeting audio is now intentionally sent for both Twilio and Exotel providers in agent.py, where previously only Twilio received it.
Applied to files:
app/ai/voice/agents/breeze_buddy/agent.pyapp/ai/voice/agents/breeze_buddy/utils/common.py
🧬 Code graph analysis (3)
app/ai/voice/agents/breeze_buddy/agent.py (1)
app/ai/voice/agents/breeze_buddy/utils/common.py (1)
prepare_daily_greeting_frame(598-676)
app/ai/voice/agents/breeze_buddy/services/daily/daily.py (3)
app/ai/voice/agents/breeze_buddy/managers/utils.py (1)
prepare_and_store_initial_greeting(12-120)app/database/accessor/breeze_buddy/lead_call_tracker.py (1)
get_lead_by_id(222-241)app/database/accessor/breeze_buddy/template.py (1)
get_template_by_merchant(35-77)
app/ai/voice/agents/breeze_buddy/utils/common.py (3)
app/ai/voice/agents/breeze_buddy/template/context.py (2)
lead(77-79)lead(82-84)app/services/redis/client.py (2)
get_redis_service(293-298)delete(232-240)app/ai/voice/agents/breeze_buddy/template/hooks.py (1)
get(263-273)
🪛 Ruff (0.14.10)
app/ai/voice/agents/breeze_buddy/agent.py
283-283: Do not catch blind exception: Exception
(BLE001)
527-527: Unused function argument: task
(ARG001)
527-527: Unused function argument: frame
(ARG001)
594-594: Do not catch blind exception: Exception
(BLE001)
app/ai/voice/agents/breeze_buddy/services/daily/daily.py
81-81: Avoid specifying long messages outside the exception class
(TRY003)
101-101: Do not catch blind exception: Exception
(BLE001)
app/ai/voice/agents/breeze_buddy/utils/common.py
672-672: Consider moving this statement to an else block
(TRY300)
674-674: Do not catch blind exception: Exception
(BLE001)
🔇 Additional comments (8)
app/ai/voice/agents/breeze_buddy/utils/common.py (2)
11-11: LGTM!The import of
TTSAudioRawFrameis correctly added alongsideOutputAudioRawFrameto support the new Daily greeting frame functionality.
598-676: LGTM! Well-structured Daily greeting preparation.The function correctly:
- Prioritizes template static greeting over lead dynamic greeting
- Cleans up temporary lead greeting from Redis after retrieval
- Converts mulaw 8kHz audio to PCM 16kHz for Daily transport compatibility
- Uses
TTSAudioRawFrameto ensure proper bot speaking signalsThe intentional omission of a dial tone fallback (unlike the telephony path) aligns with the summary—Daily mode returns
Nonewhen no greeting is available, allowing the caller to handle this gracefully.app/ai/voice/agents/breeze_buddy/services/daily/daily.py (1)
24-26: LGTM!The new imports are correctly added to support lead/template fetching and greeting preparation for the Daily session startup flow.
Also applies to: 33-33
app/ai/voice/agents/breeze_buddy/agent.py (5)
10-10: LGTM!The imports for
BotStartedSpeakingFrameandprepare_daily_greeting_frameare correctly added to support the Daily greeting flow.Also applies to: 50-51
129-129: LGTM!The new instance variables are properly initialized:
self.ttsfor storing the TTS service referenceself.daily_greeting_framefor the prepared greeting audioself._pipeline_started_eventfor pipeline synchronizationAlso applies to: 138-139
268-285: LGTM!The Daily greeting frame preparation follows the same defensive pattern as telephony mode—failures are logged as warnings and gracefully degraded to no greeting, which is appropriate for a non-critical feature.
458-458: LGTM!Storing the TTS service reference enables pushing the greeting frame later in the
on_client_connectedhandler.
526-530: LGTM!The pipeline started event handler correctly signals when the pipeline is ready. The
taskandframeparameters are required by the event handler signature even if unused—this is a false positive from static analysis.
498a761 to
1bdab53
Compare
1bdab53 to
7a1f3ee
Compare
- Extended the pre recorded audio support for daily in breeze_buddy
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.