A real-time interviewer experience using Google's Gemini Live API with the official @google/genai SDK. Talk to Gemini using your microphone and hear responses in real-time with text transcription.
- Real-time bidirectional voice communication with Gemini
- Text transcription of Gemini's responses
- Text message input option
- Browser-based microphone capture with device selection
- Audio streaming with WebSockets
- Modern, clean UI with mute and hangup controls
- Google Search integration
- Node.js (v18 or higher recommended)
- A Google API key from Google AI Studio
-
Install dependencies:
npm install
-
Configure API key:
- Copy
.env.exampleto.env - Add your Google API key to the
.envfile:GOOGLE_API_KEY=your_actual_api_key_here
- Copy
-
Start the development server:
npm run dev
-
Open in browser:
- Navigate to
http://localhost:8000 - Select your microphone from the dropdown (bottom right)
- Click the microphone button to start
- Allow microphone access when prompted
- Start talking to Gemini!
- Navigate to
-
Frontend (index.html):
- Captures microphone audio at 16kHz, 16-bit PCM, mono using AudioWorklet
- Converts audio to base64 and sends via WebSocket to backend
- Receives and plays audio responses from Gemini at 24kHz
- Displays text transcription in real-time
- Provides text input for messaging
- Mute/unmute and hangup controls
-
Backend (server.ts):
- Built with Hono framework for HTTP server
- Manages WebSocket connections from clients
- Connects to Gemini Live API using @google/genai SDK
- Forwards audio data between client and Gemini
- Handles response streaming and transcription
- Broadcasts audio and text to all connected clients
- Audio Format (Input): 16-bit PCM, 16kHz, mono
- Audio Format (Output): 24kHz from Gemini
- Model:
gemini-live-2.5-flash-preview - Voice: Zephyr
- Response Modalities: AUDIO with output transcription
- Tools: Google Search enabled
- Framework: Hono + Node.js WebSocket Server
- Runtime: tsx for TypeScript execution
- Click the microphone button to start a live conversation
- Use mute button to temporarily disable your microphone
- Use hangup button to end the session and clear audio
- Type messages in the text field and press Enter
- Gemini will respond with audio and text
- Use the dropdown in the bottom-right corner to select your audio input device
- No audio received: Check your API key is valid and has access to the Gemini Live API
- Microphone not working: Ensure browser has microphone permissions and a device is selected
- Connection errors: Verify your API key in the
.envfile - Module errors: Ensure you have Node.js v18+ and run
npm installagain - Port already in use: The server runs on port 8000 by default, ensure no other service is using it
Based on the work by jaydanurwin
For more information about the Gemini Live API, see: