Skip to content

feat(gemini): map live start- and end-of-speech sensitivity - #47139

Closed
tech-carrement wants to merge 1 commit into
BerriAI:mainfrom
tech-carrement:feat-gemini-live-vad-sensitivity
Closed

tech-carrement wants to merge 1 commit into
BerriAI:mainfrom
tech-carrement:feat-gemini-live-vad-sensitivity

Conversation

@tech-carrement

@tech-carrement tech-carrement commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Gemini Live's automaticActivityDetection accepts startOfSpeechSensitivity and endOfSpeechSensitivity, but nothing in the OpenAI-shaped turn_detection mapping filled them
  • A client that streams the microphone continuously had no way to tame an eager end-of-speech detection: sentences were cut into fragments and the user had to repeat

How it solves it:

  • turn_detection.start_of_speech_sensitivity and turn_detection.end_of_speech_sensitivity (the Gemini names in snake_case, since OpenAI has no equivalent) are forwarded to automaticActivityDetection
  • Values outside the StartOfSpeechSensitivityEnum / EndOfSpeechSensitivityEnum literals are dropped rather than sent, because Gemini closes the socket on an unknown enum value

User Flow

Before: a developer tunes turn_detection on ws://localhost:4000/v1/realtime?model=gemini-live

  1. They send session.update with silence_duration_ms and end_of_speech_sensitivity: END_SENSITIVITY_LOW
  2. The setup sent to Gemini carries only silenceDurationMs; the sensitivity is silently lost
  3. The model keeps interrupting the user mid-sentence

After: the same session.update

  1. The setup carries startOfSpeechSensitivity / endOfSpeechSensitivity next to silenceDurationMs
  2. Gemini accepts the setup and the session runs with the requested detection

Pre-Submission checklist

  • I have Added testing in the tests/unit directory, Adding at least 1 test is a hard requirement
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Proof of Fix

The setup.realtimeInputConfig built by VertexAIRealtimeConfig.transform_realtime_request from the same session.update (server_vad, silence_duration_ms: 700, both sensitivities LOW), run against each tree:

base  @ 46ae68021e setup.realtimeInputConfig = {"automaticActivityDetection": {"disabled": false, "silenceDurationMs": 700}}
pr    @ c794d231c6 setup.realtimeInputConfig = {"automaticActivityDetection": {"disabled": false, "silenceDurationMs": 700, "startOfSpeechSensitivity": "START_SENSITIVITY_LOW", "endOfSpeechSensitivity": "END_SENSITIVITY_LOW"}}

Live LiteLLM proxy at the PR tip c794d231c6, vertex_ai/gemini-3.8-live in eu, real calls, the same session.update then one user text item:

t+580ms session.updated
t+580ms >> user text item sent (turn complete)
t+1096ms response.created id=resp_7ad914dd-6385-41fd-aaca-536bb6f98d55 mod=['audio']
t+1096ms response.output_audio_transcript.delta 'Bonjour, je suis '
t+1747ms response.output_audio_transcript.delta 'DialogPro. Comment'
t+2947ms response.output_audio_transcript.delta ' vous appelez-vous ?'
t+4266ms response.done status=completed out={'audio_tokens': 88, 'reasoning_tokens': 93, 'text_tokens': 13}

Gemini accepted the setup (no 1007) and answered. Unit test: tests/unit/llms/gemini/realtime/test_gemini_realtime_transformation.py::test_gemini_maps_the_two_vad_sensitivities

Type

🆕 New Feature

Caveats

  • Low: the two fields are a Gemini-specific extension of turn_detection; other providers ignore them
  • Low: with create_response: false on a model that rejects tuning next to disabled: true, the existing early return applies and the sensitivities are not sent

Final Attestation

  • I attest that this PR is ready for review and merge

@codspeed

codspeed Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ 1 benchmark spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 32 untouched benchmarks


Comparing tech-carrement:feat-gemini-live-vad-sensitivity (c794d23) with main (3c19b41)

Open in CodSpeed

Gemini Live's automaticActivityDetection accepts startOfSpeechSensitivity and
endOfSpeechSensitivity, but nothing filled them: a client streaming the
microphone continuously saw its sentences cut into fragments by an eager
end-of-speech detection. OpenAI has no equivalent, so the client passes them
under their Gemini names in snake_case; values outside the enums are dropped.
@tech-carrement
tech-carrement force-pushed the feat-gemini-live-vad-sensitivity branch from ec3cf28 to c794d23 Compare October 17, 2026 17:52
@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@tech-carrement

Copy link
Copy Markdown
Contributor Author

Closing this temporarily: this account is capped at five open PRs on the repo and two Gemini Live protocol fixes need the slots first. The branch is unchanged (c794d23, CI green, proof in the description); I will reopen it as soon as a slot frees.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant