Watch the demo video on YouTube
polyglot-live is a Chrome Manifest V3 extension for real-time tab-audio translation suitable for live translation of audio presented in the browser tab, with:
- a side panel for controls and live status
- a readiness check that verifies local token provisioning before live start
- a right-click context menu entry for opening the side panel on the current page
- a service worker for orchestration
- an offscreen document for audio capture and playback
- a real Gemini Live Translate WebSocket client
- a local ephemeral-token server powered by Google's official
@google/genaiSDK
This build is meant for hands-on local testing of live translation workflows in Chrome.
You should use this repo if you want to test:
- live translation from browser tab audio
- live translation from microphone input
- transcript review in the side panel
- browser-native back-translation comparison
- local-AI post-session translation scoring
- replay capture and export
You should not expect:
- one-click consumer install from the Chrome Web Store
- cloud-hosted token provisioning
- perfect speaker-voice preservation
- guaranteed support on Chrome internal pages such as
chrome://
This repo now includes a real Live Translate WebSocket transport and a working local token provisioning server. It is ready for local tester installs, but each tester still needs to run the token server locally and provide a Gemini API key through environment variables.
The current build matches the documented Gemini Live Translate contract more closely and is working as a local developer build:
- product name:
Gemini 3.5 Live Translate - model:
gemini-3.5-live-translate-preview - input audio: raw 16-bit PCM, 16kHz, mono, little-endian
- output audio: raw 16-bit PCM, 24kHz, mono, little-endian
- send cadence: 100ms audio chunks
- translation target is selectable in the side panel and persists across sessions
- ephemeral tokens must use the
v1alphaconstrained WebSocket endpoint
Current UI capabilities:
- manual start only: nothing auto-starts
Input sourcesupports bothTab audioandMicrophoneStartbegins translated-only audio playback- target language is selected from a sticky dropdown and restored on reload
- the dropdown is populated from the current Gemini Live Translate supported-language list
- the panel includes
Live,Comparison, andMetricsworkflow tabs Originaland translated live text panes are collapsible- both text panes are stacked vertically, full width, and resizable
- live text panes show dialogue-only transcript content
- replay recording can be previewed and exported as MP3
- demo mode can start a random language for a short sample run
- target language can be changed during an active session and the extension will restart the live session for the new language
- translated voice rendering should be treated as best-effort, especially for multi-speaker audio
If you are handing this repo to a tester, this is the shortest working path:
- Install Node.js.
- Open PowerShell in the repo root and run
npm install. - Set
GEMINI_API_KEYand startnode .\server\token-server.mjs. - Load the folder as an unpacked extension in
chrome://extensions. - Open the side panel.
- In
Auth, confirmhttp://127.0.0.1:8787/token, enter the same shared secret if you used one, and clickCheck readiness. - Choose
Tab audioorMicrophone. - Choose a target language.
- Press
Start.
- tab audio translation starts on normal web pages with playable audio
- microphone translation starts after microphone permission is granted
- translated audio plays back in the selected target language
- live transcript panes populate during the session
- changing the target language during a live session switches the session cleanly
- comparison tab generates browser-native back-translation after a session
- metrics tab generates local-AI scoring after comparison is available
- replay recording can be started, stopped, previewed, and exported
- theme, language, and other sticky settings survive reloads
When the extension is working properly, testers should expect these main UI areas:
-
Translation ControlsUse this section to chooseTab audioorMicrophone, select the target language, adjust original audio mix, and start or stop the live session. -
Live TextThis is the main workflow area. TheLivetab shows original and translated transcript panes. TheComparisontab is for browser-native back-translation review. TheMetricstab is for local-AI scoring after the session. -
UtilitiesThis area holds support items likeAuth,Audio Alignment, andStatus, so testers can confirm the token server is reachable and inspect session state when troubleshooting. -
RecordingThis section supports replay capture, replay preview, and MP3 export for translated audio.
If you are packaging this for testers, adding 2 to 4 screenshots to the repo or release notes is recommended:
- the side panel at first launch
- the
Authreadiness success state - a live translation session with transcript text visible
- a completed
ComparisonorMetricsreview state
- The user opens the side panel on a source tab.
- The side panel asks the service worker to start a capture session.
- The service worker creates the offscreen document if needed and requests a tab stream id.
- The offscreen document converts the captured tab audio into 16kHz PCM chunks and streams them to Gemini Live Translate over WebSocket.
- The token server provisions short-lived ephemeral tokens from your long-lived Gemini API key.
- Translated 24kHz PCM audio is played back from the offscreen document and status messages are relayed back to the side panel.
manifest.json: MV3 config, permissions, side panel, and offscreen setupconfig.js: shared model, audio, and endpoint constantsbackground.js: service worker orchestrationsidepanel.html,sidepanel.css,sidepanel.js: control surfaceoffscreen.html,offscreen.js: hidden audio pipeline host and Gemini WebSocket clientserver/token-server.mjs: local ephemeral-token provisioning server using@google/genaipackage.json: local Node package metadata and SDK dependency
Before using the extension, make sure you have:
- Google Chrome desktop with Developer mode available in
chrome://extensions - Node.js installed locally
- A Gemini API key from Google AI Studio
- The project dependency installed from the repo root:
cd <repo-root>
npm installIf you already ran setup in this folder, @google/genai should already be present under node_modules.
Chrome version guidance:
- use current desktop Chrome stable whenever possible
ComparisonandMetricsdepend on Chrome built-in AI APIs and should be treated as Chrome 138+ featuresTranslator APIsupport for the browser-native comparison flow is desktop-onlyMetricsalso depends on Chrome local AI hardware and storage requirements on the tester's machine
To create a Gemini API key for local testing:
- Go to Google AI Studio and sign in with your Google account.
- If prompted, accept the current terms of service.
- Open the API key flow from the official AI Studio
Get API keyentry point. - Create a key in the default project AI Studio gives you, or choose/import an existing Google Cloud project.
- Copy the key immediately and store it safely.
- Use that key only in your local token-server shell session through
GEMINI_API_KEY.
Important notes:
- as of June 23, 2026, Google documents a free tier for Gemini API usage and lists
gemini-3.5-live-translate-previewas free on that tier - new AI Studio keys are now created as authorization keys by default
- every Gemini key is still tied to a Google Cloud project, even when created through AI Studio
- testers should watch the official pricing page because preview pricing can change
- you should treat the key as sensitive even when using the free tier
Open PowerShell in the repo root:
cd <repo-root>Use this exact startup sequence in PowerShell:
cd <repo-root>
$env:GEMINI_API_KEY="your-real-gemini-api-key"
$env:POLYGLOT_LIVE_SHARED_SECRET="your-local-secret"
node .\server\token-server.mjsExpected server output:
polyglot-live token server listening at http://127.0.0.1:8787/token
polyglot-live readiness probe available at http://127.0.0.1:8787/status
Then use these same values in the side panel:
Token endpoint:http://127.0.0.1:8787/tokenShared secret: the exact same value you used inPOLYGLOT_LIVE_SHARED_SECRET
Notes:
GEMINI_API_KEYis your real Google AI Studio API keyPOLYGLOT_LIVE_SHARED_SECRETis just a local secret you choose yourself- the shared secret is not registered with Gemini; it only protects your local token server
Use your Gemini API key only on the local token server side.
Pricing note:
- as of June 23, 2026, Google's official Gemini API pricing page lists
gemini-3.5-live-translate-previewasFree of chargeon the free tier - this can change when Google moves the preview model to a paid phase or replaces it with a production model
- testers should keep an eye on the official Gemini pricing page before assuming live translation remains free
- even during free preview, users should still protect their API key as if it were a paid credential
Safe practices for this repo:
- do keep
GEMINI_API_KEYin an environment variable - do keep the key out of
README.md, source files, screenshots, and chat messages - do keep the key out of the Chrome side panel; the extension should talk only to your local token server
- do keep
node_modules/and other local-only files out of git;.gitignorealready excludes them - do rotate the key in Google AI Studio if you think it was pasted somewhere unsafe
- do use a temporary PowerShell session variable when possible
Do not:
- do not hard-code the key in
background.js,offscreen.js,config.js, or any extension file - do not commit the key to git, even in a private repo
- do not store the real key in Chrome extension storage
- do not share the real key in screenshots or copied terminal history
Recommended local pattern for a single PowerShell session:
$env:GEMINI_API_KEY="your-real-gemini-api-key"
$env:POLYGLOT_LIVE_SHARED_SECRET="optional-local-secret"
node .\server\token-server.mjsThat keeps the key in the current shell session only. Closing that shell drops the value.
If you want a persistent Windows environment variable, use setx, but treat that as less private because it stays on the machine after the shell closes:
setx GEMINI_API_KEY "your-real-gemini-api-key"After using setx, open a new PowerShell window before starting the token server.
Then set your environment variables before starting the token server:
$env:GEMINI_API_KEY="your-real-gemini-api-key"
$env:POLYGLOT_LIVE_SHARED_SECRET="optional-local-secret"
node .\server\token-server.mjsIf you want a fast local test, you can skip the shared secret and run:
cd <repo-root>
$env:GEMINI_API_KEY="your-real-gemini-api-key"
node .\server\token-server.mjsThe side panel defaults to http://127.0.0.1:8787/token. The shared secret is something you choose locally; it is not registered with Gemini.
When the server starts successfully, it should print:
polyglot-live token server listening at http://127.0.0.1:8787/token
polyglot-live readiness probe available at http://127.0.0.1:8787/status
- Open
chrome://extensions. - Enable Developer mode.
- Click Load unpacked.
- Select this repo checkout folder.
- Open the side panel.
- Leave the token endpoint as
http://127.0.0.1:8787/tokenunless you changed the server host or port. - If you set
POLYGLOT_LIVE_SHARED_SECRET, enter that exact same value in the side panel's shared secret field.
Important tab-capture limits:
- tab audio capture does not work on
chrome://pages - tab audio capture does not work on the Chrome Web Store
- tab audio capture does not work on other browser-internal pages
Before pressing Start, click Check readiness in the Auth card.
If everything is healthy, you should see:
Ready: local token server reachable and Gemini token accepted.- the main status badge move to
READY
If it fails, the panel should tell you whether the issue is:
- the local token server is not running
- the shared secret does not match
- Gemini token provisioning failed
The readiness check verifies the same token path that the offscreen Live session uses.
Important current behavior:
- the side panel does not auto-start translation
- the right-click menu opens the side panel but does not start translation
Tab audioandMicrophoneare both supported input sources- the side panel remembers the last selected target language
- the extension currently plays translated audio only
- a microphone permission grant is not the same as translation-ready; the live session is only ready once the panel shows the ready/live state for the active session
- if you change target language during an active session, the extension restarts the live session for the new language
Stopshuts down the current offscreen Gemini session before restart
Recommended flow:
- Start the local token server
- Reload the unpacked extension
- Open the side panel
- Click
Check readiness - Choose
Tab audioorMicrophone - If using microphone mode, grant microphone access first
- If using tab mode, start the source audio on a normal website tab
- Press
Startonly after the panel reports readiness - Wait for the live session ready indicator before judging translation startup timing
The token server validates the selected language against the shared supported-language list before provisioning the ephemeral token.
After a translation session:
- Open the
Comparisontab to generate a browser-native back-translation of the translated transcript. - Review the original transcript and back-translation together.
- Open the
Metricstab to generate local-AI scoring and reviewer notes.
Current behavior notes:
- comparison and metrics are intended as post-session review tools
- metrics depend on comparison output being available first
- comparison and metrics results stay visible until you manually clear text or start a fresh session
The Recording section supports:
- start recording during a live translation session
- stop recording and keep the captured replay
- replay the captured translated audio locally
- export the replay as MP3
Recording is tied to the active session tab. Start translation first, then use the recording controls on that same tab session.
- translated voice identity is best-effort and may not reliably preserve speaker gender or speaker changes
- tab audio capture is limited by Chrome page restrictions
- browser-native comparison depends on Chrome built-in AI availability and supported language pairs
- metrics depend on Chrome local AI availability on the tester's device
- this is still a local test build, so the token server must run on the tester's machine
Gemini Live Translate currently handles translated voices on a best-effort basis.
Important current limits from the Google documentation:
- voice replication can shift after long pauses
- the model can assign the wrong gender based on how speech begins
- rapid multi-speaker conversations can collapse onto a single translated voice
So while a male/female two-speaker source may sometimes sound distinct in the translated output, this should not be treated as a guaranteed feature of the current Live Translate pipeline.
Useful places to look while testing:
- Side panel console: inspect the side panel window
- Extension service worker console: open it from
chrome://extensions - Token server console: the PowerShell window running
node .\server\token-server.mjs
Current background logs include messages such as:
[polyglot-live/background] installed[polyglot-live/background] rebuilding context menu[polyglot-live/background] preparing translation session[polyglot-live/background] tab capture stream acquired[polyglot-live/background] stop requested
Current offscreen logs include messages such as:
[polyglot-live/offscreen] requesting ephemeral token[polyglot-live/offscreen] ephemeral token accepted[polyglot-live/offscreen] websocket open[polyglot-live/offscreen] setup complete- translated audio packet receipts and active session close messages
- Improve approximate translated-word timing so the highlight tracks speech more naturally.
- Add richer reconnect and session-resumption handling around
goAwayand websocket churn. - Consider a searchable language picker now that the dropdown includes the full supported list.
- Move the shared-secret check to a stronger user auth scheme if this leaves local-only development.
- Add packaging, logging controls, and extension options UX.