You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A minimal command-line app that streams microphone audio to the Gemini Live API and plays back the response in real time. This example is intended for local testing only, not for production use cases.
4
+
5
+
> **Note:** Use headphones. This script uses the system default audio input and output, which often won't include echo cancellation. To prevent the model from interrupting itself, use headphones.
6
+
7
+
## Prerequisites
8
+
9
+
- Node.js 20+
10
+
- A Gemini API key ([get one here](https://aistudio.google.com/apikey))
11
+
- SoX (`brew install sox` on macOS) — required by the `mic` package
12
+
13
+
## Setup
14
+
15
+
Install helpers for audio streaming. Additional system-level dependencies might be required (`sox` for Mac/Windows or ALSA for Linux). Refer to the [speaker](https://www.npmjs.com/package/speaker) and [mic](https://www.npmjs.com/package/mic) docs for detailed installation steps.
16
+
17
+
```bash
18
+
npm install @google/genai mic speaker
19
+
```
20
+
21
+
## Run
22
+
23
+
```bash
24
+
export GEMINI_API_KEY="your-api-key"
25
+
npx tsx main.mts
26
+
```
27
+
28
+
You should see **"Connected to Gemini Live API"** and **"Microphone started. Speak now..."** — talk into your mic and Gemini will respond with audio. Press `Ctrl+C` to quit.
0 commit comments