> For the complete documentation index, see [llms.txt](https://maha-strategies-llc.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://maha-strategies-llc.gitbook.io/docs/core-concepts/the-agentic-core-real-time-audio-bridge.md).

# The Agentic Core: Real-Time Audio Bridge

Maha OS features a live, voice-to-voice negotiation system powered by Google's Gemini infrastructure. Because the ecosystem relies on web-based audio APIs wrapped in a native Capacitor shell, standard WebRTC implementations result in severe hardware routing conflicts on Android devices (specifically, the OS trapping audio in the "Earpiece" channel).

\
**The Uplink Protocol (Raw Mic Capture)**

\
To prevent Android's `AudioManager` from hijacking the audio stream into a VoIP "Phone Call" state, the system requests a raw, unfiltered media stream.<br>

* **Hardware Constraints:** `echoCancellation: false`, `noiseSuppression: false`, and `autoGainControl: false` must be explicitly defined.<br>
* **Processing:** The stream is captured at 16kHz via a `ScriptProcessorNode`, converted to 16-bit PCM, and emitted over WebSockets as Base64 to the backend Node.js relay.<br>

**The Downlink Protocol (WAV Header Injection)**

\
The system utilizes a Sequential Playback Queue rather than a raw `AudioContext` to force playback through the primary Loudspeaker.<br>

* **Header Synthesis:** Raw 24kHz PCM chunks received from Gemini are dynamically wrapped in a standard 44-byte RIFF/WAVE header on the client side.<br>
* **Sequential Engine:** The Blob is converted to a generic HTML5 `new Audio()` element. Because the Android OS recognizes this as standard media (analogous to a music player), it successfully routes the Agentic Core's voice through the primary speaker hardware, bypassing the earpiece lock.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://maha-strategies-llc.gitbook.io/docs/core-concepts/the-agentic-core-real-time-audio-bridge.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
