Add WebSocket endpoint for streaming audio transcription#99
Open
leonbaronick wants to merge 4 commits into
Open
Add WebSocket endpoint for streaming audio transcription#99leonbaronick wants to merge 4 commits into
leonbaronick wants to merge 4 commits into
Conversation
Added StreamConfig, StreamEvent types and event constants for the WebSocket streaming transcription protocol.
StreamSession implements chunked audio processing mirroring whisper.cpp's stream example. AcquireTask allows long-lived task ownership for streaming sessions.
Adds the /stream WebSocket endpoint that accepts PCM audio and returns transcription segments in real time. Integrates with the manager layer via NewStreamSession.
Update README features list and API docs with the WebSocket streaming transcription protocol, configuration parameters, and event format.
Member
|
Hi Leon. Thanks for the PR! Sorry for the late reply but I will take a look at the weekend and get back to you. |
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.
Hi there! I've been looking for a server-client-split implementation for whisper.cpp and discovered go-whisper. I need real-time microphone transcription though, so I took the liberty of implementing a WebSocket streaming endpoint. Happy to adjust the approach if it doesn't fit your vision for the project.
I'm also working on a seperate branch to add microphone recording on the client-side, although that is maybe not that suitable for the CLI application.
Summary
Adds a WebSocket endpoint (
GET /api/whisper/stream) that accepts real-time audio input and returns transcription segments as they are produced. This uses a sliding-window approach mirroring https://github.com/ggml-org/whisper.cpp/blob/master/examples/stream/stream.cpp. Audio is accumulated andwhisper_full()is called repeatedly on overlapping windows with timestamp-based segment deduplication.Protocol: Client connects via WebSocket, sends a JSON config (model, language, window parameters), then streams binary PCM frames (16-bit LE, 16kHz mono). The server responds with JSON segment events as they're transcribed.
Key changes
pkg/schema/stream.go: StreamConfig and StreamEvent typespkg/whisper/stream.go: StreamSession implementing sliding-window processing with configurable step_ms, length_ms, keep_ms, and a simple RMS-based VAD gatepkg/whisper/whisper.go: AcquireTask() for long-lived task ownership (streaming sessions hold a context for their duration, unlike the per-request WithModel pattern)pkg/manager.go: NewStreamSession() with model validation (local whisper models only)pkg/httphandler/stream.go: WebSocket handler with PCM-to-float32 conversionLimitations
--whisper.max-contexts