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
Copy file name to clipboardExpand all lines: README.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,6 +60,11 @@ Live API:
60
60
61
61
***[Gen AI SDK Python example](./gemini-live-genai-python-sdk/README.md)**: Recommended for ease of use. Connect to the Gemini Live API using the Gen AI SDK to build a real-time multimodal application with a Python backend.
62
62
***[Epheremal tokens and raw WebSocket example](./gemini-live-ephemeral-tokens-websocket/README.md)**: RAW protocol control. Connect to the Gemini Live API using WebSockets to build a real-time multimodal application with a JavaScript frontend and a Python backend.
63
+
***[Command-line Python example](./command-line/python/README.md)**: A minimal command-line app that streams microphone audio to the Gemini Live API and plays back the response in real time using Python.
64
+
***[Command-line Node.js example](./command-line/node/README.md)**: A minimal command-line app that streams microphone audio to the Gemini Live API and plays back the response in real time using Node.js.
65
+
66
+
> [!TIP]
67
+
> Install the [Gemini Live API Dev](https://github.com/google-gemini/gemini-skills?tab=readme-ov-file#gemini-live-api-dev) skill for AI-assisted development with the Live API in your coding agents.
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