NavigoAI_Voice_Agent_ADk
Health Uyari
- No license — Repository has no license file
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Community trust — 21 GitHub stars
Code Basarisiz
- Hardcoded secret — Potential hardcoded credential in server/streaming_service.py
Permissions Gecti
- Permissions — No dangerous permissions requested
Bu listing icin henuz AI raporu yok.
Real-time voice travel agent on Gemini native audio + Google ADK, with Google Search and Maps MCP tools.
NaviGo AI: Real-Time Voice Travel Agent with Gemini & Google ADK
A voice-first travel assistant that streams live audio between the browser and Gemini's native-audio model through the Google Agent Development Kit (ADK), with Google Search and Google Maps (MCP) tools.
[!NOTE]
Featured on the Google Cloud Blog: Build a real-time voice agent with Gemini & ADK. The full walkthrough is also in docs/blog.md.
📖 Overview
Classic voice assistants chain Speech-to-Text, an LLM and Text-to-Speech. Each hop adds latency and strips out tone. NaviGo AI uses Gemini's native-audio model end to end: raw microphone audio goes to the model and spoken audio comes back over one bidirectional ADK session. The agent answers general travel questions with Google Search and route or location questions with the Google Maps MCP server (@modelcontextprotocol/server-google-maps).
🧭 What I built, step by step
- Agent. An ADK
Agentwith the NaviGo AI travel persona (SYSTEM_INSTRUCTIONincore_utils.py). Model and voice come fromMODELandVOICE_NAMEso I can swap native-audio models without touching code. - Tools. ADK's built-in
google_searchfor open travel questions, plus anMCPToolsetthat launches the Google Maps MCP server over stdio vianpx. Using MCP meant I got directions and place lookups without writing a Maps client. - WebSocket server.
BaseStreamServer(websockets, port 8080) accepts browser connections and sends areadymessage once the session is up. - Live session. Each connection gets its own
InMemorySessionServicesession, aLiveRequestQueue, andRunner.run_livewithStreamingMode.BIDI,response_modalities=["AUDIO"]and input/output transcription enabled. - Concurrent pipeline. An
asyncio.TaskGroupper client runs four tasks: receive client messages, forward audio, forward JPEG frames, and relay model audio, transcripts,interruptedandturn_completeevents. Separating them keeps playback flowing while the user is still talking, which is what makes barge-in work. - Browser client.
sound_handler.jscaptures the mic as 16 kHz PCM16 and plays 24 kHz PCM back, stopping playback oninterrupted.stream_manager.jsadds webcam and screen-frame capture.interface.htmlshows the live transcript. - Write-up. I wrote the build guide that ran on the Google Cloud Blog (docs/blog.md).
🏗️ Architecture
Target architecture on Google Cloud. Run locally today; this is the production target.

- Gemini Live API (Vertex AI or Gemini API): receives the 16 kHz PCM stream and returns 24 kHz speech plus transcripts.
google_searchruns as Gemini grounding. - Cloud Run: hosts
server/streaming_service.py(WebSocket on :8080,Runner.run_livein BIDI mode), with the Maps MCP server launched in the same container vianpx. - HTTPS Load Balancer + Cloud Storage: terminates TLS for
wss://traffic (optionally behind IAP) and serves the staticclient/files. - Secret Manager + IAM service account: injects
GOOGLE_MAPS_API_KEYat runtime; a least-privilege service account calls Vertex AI. - Cloud Build + Artifact Registry: build, store and deploy the container image.
- Cloud Logging + Cloud Monitoring: server logs, session errors, latency and connection metrics.
Diagram source: docs/architecture/gcp_architecture.py, rendered with diagrams.
Request flow
sequenceDiagram
participant U as User (browser)
participant C as Client JS
participant S as StreamingService
participant A as ADK Runner / Agent
participant G as Gemini Live
participant T as Tools (Search / Maps MCP)
C->>S: WebSocket connect
S-->>C: {"type": "ready"}
U->>C: Click mic & speak
loop While recording
C->>S: {"type": "audio", "data": base64 PCM 16 kHz}
S->>A: LiveRequestQueue.send_realtime(Blob)
A->>G: Stream audio
end
G-->>A: Tool call (optional)
A->>T: google_search / Maps MCP
T-->>A: Result
G-->>A: Audio chunks + transcriptions
A-->>S: Live events
S-->>C: audio / text / user_transcript
C-->>U: Play 24 kHz audio, show transcript
S-->>C: turn_complete or interrupted
✨ Key Features
- Native-audio conversation with a configurable prebuilt voice.
- Bidirectional streaming through
Runner.run_live,StreamingMode.BIDIand aLiveRequestQueue. - Live transcription of both sides, sent to the UI as
user_transcriptandtextmessages. - Barge-in: the server forwards
interruptedevents and the client stops playback. - Tool use mid-conversation:
google_searchplus the Google MapsMCPToolset. - Multimodal input: the server accepts JPEG frames (
type: "video").stream_manager.jshas webcam and screen-share capture; the default UI doesn't expose a button for it. - Session resumption handles are forwarded to the client as
session_idmessages when Gemini issues them.
🧰 Tech Stack
| Layer | Technology |
|---|---|
| Agent framework | Google ADK (google-adk) |
| Model | Gemini 2.5 Flash native audio (set via MODEL) |
| Tools | ADK google_search, Google Maps MCP server |
| Server | Python 3.11+, asyncio, websockets, python-dotenv |
| Client | HTML, Tailwind CSS (CDN), vanilla JavaScript, Web Audio API, MediaDevices API |
📁 Repository Structure
.
├── client/
│ ├── interface.html # UI: mic button, transcript, audio indicator
│ ├── sound_handler.js # WebSocket client, mic capture (16 kHz), playback (24 kHz)
│ └── stream_manager.js # Adds webcam/screen frame streaming
├── server/
│ ├── core_utils.py # Env config, system instruction, BaseStreamServer
│ ├── streaming_service.py # Agent, tools, live session and streaming tasks (entry point)
│ ├── requirements.txt
│ ├── start_servers.sh
│ └── .env.example
├── docs/
│ ├── architecture/ # GCP diagram and its source
│ └── blog.md # Build guide
└── README.md
🚀 Getting Started
Prerequisites
- Python 3.11+ (the server uses
asyncio.TaskGroup) - Node.js with
npx, to launch the Maps MCP server - A Gemini API key from Google AI Studio, or a Google Cloud project with Vertex AI enabled
- A Google Maps Platform API key
- A browser with microphone access
1. Clone and install
git clone https://github.com/Ashwinikumar1/NavigoAI_Voice_Agent_ADk.git
cd NavigoAI_Voice_Agent_ADk/server
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
2. Configure environment variables
cp .env.example .env
| Variable | Used by | Description |
|---|---|---|
GOOGLE_API_KEY |
google-genai SDK | Gemini API key (when GOOGLE_GENAI_USE_VERTEXAI=FALSE) |
GOOGLE_GENAI_USE_VERTEXAI |
google-genai SDK | FALSE for Gemini API key, TRUE for Vertex AI |
GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_LOCATION |
google-genai SDK | Vertex AI only |
MODEL |
core_utils.py |
Native-audio model, e.g. gemini-2.5-flash-preview-native-audio-dialog |
VOICE_NAME |
core_utils.py |
Prebuilt voice, e.g. Puck |
PROJECT_ID, LOCATION |
core_utils.py |
Project and region |
GOOGLE_MAPS_API_KEY |
streaming_service.py |
Passed to the Maps MCP server |
server/.env is git-ignored. Keep it that way.
3. Run the server
./start_servers.sh # or: python3 streaming_service.py
The server listens on ws://localhost:8080.
4. Open the client
Open client/interface.html directly, or serve it with python3 -m http.server -d client 5500 and visit http://localhost:5500/interface.html. The page connects to ws://localhost:8080 on load.
💬 Usage
- Click the mic button and allow microphone access.
- Ask a travel question:
- "What are the must-see places in Jaipur for a weekend trip?" uses Google Search.
- "How long does it take to drive from Bangalore to Mysore?" uses Google Maps MCP.
- NaviGo AI answers out loud while the transcript fills in. Speak over it to interrupt.
To change behaviour, edit SYSTEM_INSTRUCTION in server/core_utils.py. To change tools or the port, edit Agent(tools=[...]) and StreamingService(host="0.0.0.0", port=8080) in server/streaming_service.py; update the URL in client/interface.html if the port changes.
WebSocket message protocol
| Direction | type |
Payload |
|---|---|---|
| Client → Server | audio |
base64 PCM16, 16 kHz |
| Client → Server | video |
base64 JPEG frame, mode: webcam / screen |
| Client → Server | end / text |
turn end marker / text (logged) |
| Server → Client | ready |
sent on connect |
| Server → Client | audio |
base64 PCM, 24 kHz |
| Server → Client | text / user_transcript |
model / user transcription chunks |
| Server → Client | interrupted / turn_complete |
turn state |
| Server → Client | session_id |
session resumption handle |
🔐 Security
- Secrets: API keys live in
server/.env;server/.env.exampleholds placeholders. In production, putGOOGLE_MAPS_API_KEYin Secret Manager and use Vertex AI with a service account instead of a Gemini API key. - Least privilege: run Cloud Run as a dedicated service account with only
roles/aiplatform.userandroles/secretmanager.secretAccessoron the needed secrets. Restrict the Maps key by API and referrer or IP. - Endpoint auth: the local WebSocket is unauthenticated
ws://. In production, servewss://behind an HTTPS load balancer, validate an IAP or ID token on connect, and enforce anOriginallow-list. - Input validation: check message
type, cap payload size and rate per connection, and reject malformed base64 before it reaches the model. - Voice data: audio and transcripts are held in memory only. Don't log raw audio or transcripts, and tell users they are being recorded.
- Tool guardrails: treat search results and Maps data as untrusted. Keep tools read-only and use ADK
before_tool_callbackor model callbacks to filter arguments and responses. - Audit logging: enable Cloud Audit Logs for Vertex AI and Secret Manager; log connection and session IDs, not content.
🚢 Path to Production
- Deploy: containerize
server/(Python plus Node.js fornpx) and deploy to Cloud Run with session affinity, long request timeouts for WebSockets, and min instances to avoid cold starts. Serveclient/from Cloud Storage or Firebase Hosting. - CI/CD: a Cloud Build trigger runs lint and tests, pushes the image to Artifact Registry, and deploys with staged traffic splitting.
- State: swap
InMemorySessionServicefor a persistent session service so sessions survive across instances. - Observability: structured logs in Cloud Logging; time-to-first-audio, interruption and tool-error metrics in Cloud Monitoring; traces in Cloud Trace.
- Evaluation: an ADK eval set of travel queries that checks tool choice (Search vs Maps), grounding and persona before each release.
- Scaling and cost: every connection holds a long-lived Live session. Set per-instance concurrency, max session length and idle timeouts, and put budget alerts on Gemini Live and Maps API usage.
- Governance: pin model versions, pin the Maps MCP package version, and apply VPC Service Controls where required.
👤 Author
Ashwini Kumar · github.com/Ashwinikumar1
Yorumlar (0)
Yorum birakmak icin giris yap.
Yorum birakSonuc bulunamadi