Skip to content

feat: use deepgram-java-sdk for Flux transcription - #6

Draft
GregHolmes wants to merge 1 commit into
mainfrom
feat/use-deepgram-sdk
Draft

feat: use deepgram-java-sdk for Flux transcription#6
GregHolmes wants to merge 1 commit into
mainfrom
feat/use-deepgram-sdk

Conversation

@GregHolmes

Copy link
Copy Markdown

What

Migrates the Deepgram-facing side of the Flux (Listen v2) real-time transcription starter from a raw Jetty WebSocketClient proxy to the official Deepgram Java SDK 0.7.1 (client.listen().v2().v2WebSocket()).

How

Surgical — only the Deepgram-facing code changed. The browser-facing Javalin server, JWT subprotocol auth, /api/session, /api/metadata, /health, the /api/flux route, and graceful shutdown are unchanged, so the frontend needs no edits.

  • App.java
    • Removed the outbound Jetty WebSocketClient and the @WebSocket DeepgramSocket inner class.
    • Per connection: deepgram.listen().v2().v2WebSocket(). Handlers registered before connect: onMessage (forwards Deepgram's raw Flux JSON verbatim to the browser — preserving the native wire format the frontend parses: type, event, turn_index, transcript, words, end_of_turn_confidence), onError, onDisconnected (mapped to safe client close codes).
    • Browser → Deepgram: binary PCM → sendMedia(ByteString.of(...)); {"type":"CloseStream"}sendCloseStream(...). A small FluxBridge buffers audio that arrives before the async connect() completes.
    • Query params map to V2ConnectOptions: modelListenV2Model.valueOf, encodingListenV2Encoding.valueOf, sample_rateListenV2SampleRate.of, eot_thresholdListenV2EotThreshold.of, eager_eot_thresholdListenV2EagerEotThreshold.of, eot_timeout_msListenV2EotTimeoutMs.of, keyterm (multi) → ListenV2Keyterm.of(list).
    • Added optional DEEPGRAM_BASE_URL custom-environment support (parity with java-flux-tts).
  • pom.xml: added com.deepgram:deepgram-java-sdk:0.7.1; removed the now-unused org.eclipse.jetty.websocket:websocket-jetty-client.
  • deepgram.toml: sdk = "N/A"sdk = "deepgram-java-sdk".

Verified

  • mvn -q -DskipTests compile succeeds against 0.7.1 (Java 17 / Maven 3.9); produces App.class + App$FluxBridge.class, no leftover proxy classes.
  • Confirmed the browser contract against the flux-html frontend submodule: it sends binary PCM + a single {"type":"CloseStream"}, and parses native Deepgram JSON — all preserved.

Notes / unmapped params

  • The old proxy accepted a channels query param (default 1). Flux is mono-only and V2ConnectOptions exposes no channels setter, so it is dropped. The frontend never sends channels, so there is no behavior change.

Manual verification needed

  • make init + make start; connect from the browser, speak, and confirm turn events (StartOfTurn / Update / EagerEndOfTurn / EndOfTurn / TurnResumed) and transcripts render as before.
  • Confirm /api/session and /api/metadata behave unchanged and auth still rejects missing/invalid tokens (4401).
  • Confirm graceful CloseStream on disconnect.
  • Frontend requires no changes.

Replace the raw Jetty WebSocket proxy to Deepgram's Flux API with the official Deepgram Java SDK (client.listen().v2().v2WebSocket()).

- App.java: swap the outbound Jetty WebSocketClient/DeepgramSocket for the SDK's V2WebSocketClient. Deepgram's native Flux JSON is forwarded to the browser verbatim via onMessage, and client audio/CloseStream is bridged via sendMedia/sendCloseStream, so the frontend contract is unchanged. Query params (model, encoding, sample_rate, eot_threshold, eager_eot_threshold, eot_timeout_ms, keyterm) map to V2ConnectOptions.
- pom.xml: add com.deepgram:deepgram-java-sdk:0.7.1; drop the now-unused Jetty websocket-jetty-client dependency.
- deepgram.toml: set sdk = "deepgram-java-sdk".
@GregHolmes GregHolmes self-assigned this Jul 30, 2026
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