Skip to content

feat: Added Pre Recorded Audio Support For Daily#476

Open
manas-narra wants to merge 1 commit intojuspay:releasefrom
manas-narra:add-pre-recorded-audio-support-for-daily
Open

feat: Added Pre Recorded Audio Support For Daily#476
manas-narra wants to merge 1 commit intojuspay:releasefrom
manas-narra:add-pre-recorded-audio-support-for-daily

Conversation

@manas-narra
Copy link
Collaborator

@manas-narra manas-narra commented Jan 7, 2026

  • Extended the pre recorded audio support for daily in breeze_buddy

Summary by CodeRabbit

Release Notes

  • New Features
    • Added automatic greeting messages for Daily mode voice sessions that play upon bot startup, with graceful error handling.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review

Walkthrough

The 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

Cohort / File(s) Summary
Greeting Utility
app/ai/voice/agents/breeze_buddy/utils/common.py
Added async function prepare_daily_greeting_frame() to retrieve greeting audio from Redis (template-static or lead-dynamic preference), convert mulaw data (8kHz) to PCM 16kHz mono format, and wrap in TTSAudioRawFrame; includes fallback to None on missing audio or failures.
Daily Session Setup
app/ai/voice/agents/breeze_buddy/services/daily/daily.py
Integrated lead and template data retrieval in start_daily_session(), added lead validation with error handling, and introduced prepare_and_store_initial_greeting() to preload greeting audio in Redis before room creation; maintains graceful fallback if preparation fails.
Agent Greeting Integration
app/ai/voice/agents/breeze_buddy/agent.py
Stores TTS service reference on agent instance, introduces pipeline-started event handler for synchronization, preloads greeting frames during Daily startup, and implements greeting playback flow that waits for pipeline readiness before pushing greeting frames via TTS with fallback error handling.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 Greetings now prepare with care,
Redis whispers templates fair,
Pipelines sync, frames aligned,
Daily welcomes, warmly signed!
Audio flows through channels bright, 🎵

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: Added Pre Recorded Audio Support For Daily' directly and clearly describes the main change—adding pre-recorded audio support for Daily transport, which is reflected across all modified files.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in agent.py (line 220) using the same lead_id. Similarly, the template is fetched here (lines 86-90) and again in agent.py via _load_template_config. This results in redundant database queries.

Consider passing the fetched lead and template objects to the bot via runner_args.body instead of just the lead_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

📥 Commits

Reviewing files that changed from the base of the PR and between f512c00 and 498a761.

📒 Files selected for processing (3)
  • app/ai/voice/agents/breeze_buddy/agent.py
  • app/ai/voice/agents/breeze_buddy/services/daily/daily.py
  • app/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.py
  • app/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 TTSAudioRawFrame is correctly added alongside OutputAudioRawFrame to 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 TTSAudioRawFrame to ensure proper bot speaking signals

The intentional omission of a dial tone fallback (unlike the telephony path) aligns with the summary—Daily mode returns None when 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 BotStartedSpeakingFrame and prepare_daily_greeting_frame are correctly added to support the Daily greeting flow.

Also applies to: 50-51


129-129: LGTM!

The new instance variables are properly initialized:

  • self.tts for storing the TTS service reference
  • self.daily_greeting_frame for the prepared greeting audio
  • self._pipeline_started_event for pipeline synchronization

Also 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_connected handler.


526-530: LGTM!

The pipeline started event handler correctly signals when the pipeline is ready. The task and frame parameters are required by the event handler signature even if unused—this is a false positive from static analysis.

@manas-narra manas-narra force-pushed the add-pre-recorded-audio-support-for-daily branch from 498a761 to 1bdab53 Compare January 20, 2026 04:35
@manas-narra manas-narra force-pushed the add-pre-recorded-audio-support-for-daily branch from 1bdab53 to 7a1f3ee Compare January 27, 2026 06:16
  - Extended the pre recorded audio support for daily in breeze_buddy
@manas-narra manas-narra reopened this Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant