feat: use deepgram-java-sdk for Flux transcription - #6
Draft
GregHolmes wants to merge 1 commit into
Draft
Conversation
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".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Migrates the Deepgram-facing side of the Flux (Listen v2) real-time transcription starter from a raw Jetty
WebSocketClientproxy 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/fluxroute, and graceful shutdown are unchanged, so the frontend needs no edits.App.javaWebSocketClientand the@WebSocket DeepgramSocketinner class.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).sendMedia(ByteString.of(...));{"type":"CloseStream"}→sendCloseStream(...). A smallFluxBridgebuffers audio that arrives before the asyncconnect()completes.V2ConnectOptions:model→ListenV2Model.valueOf,encoding→ListenV2Encoding.valueOf,sample_rate→ListenV2SampleRate.of,eot_threshold→ListenV2EotThreshold.of,eager_eot_threshold→ListenV2EagerEotThreshold.of,eot_timeout_ms→ListenV2EotTimeoutMs.of,keyterm(multi) →ListenV2Keyterm.of(list).DEEPGRAM_BASE_URLcustom-environment support (parity withjava-flux-tts).pom.xml: addedcom.deepgram:deepgram-java-sdk:0.7.1; removed the now-unusedorg.eclipse.jetty.websocket:websocket-jetty-client.deepgram.toml:sdk = "N/A"→sdk = "deepgram-java-sdk".Verified
mvn -q -DskipTests compilesucceeds against0.7.1(Java 17 / Maven 3.9); producesApp.class+App$FluxBridge.class, no leftover proxy classes.flux-htmlfrontend submodule: it sends binary PCM + a single{"type":"CloseStream"}, and parses native Deepgram JSON — all preserved.Notes / unmapped params
channelsquery param (default1). Flux is mono-only andV2ConnectOptionsexposes nochannelssetter, so it is dropped. The frontend never sendschannels, 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./api/sessionand/api/metadatabehave unchanged and auth still rejects missing/invalid tokens (4401).