Add transcript reset feature on a websocket connection#423
Open
Yadav-Roshan wants to merge 1 commit intocollabora:mainfrom
Open
Add transcript reset feature on a websocket connection#423Yadav-Roshan wants to merge 1 commit intocollabora:mainfrom
Yadav-Roshan wants to merge 1 commit intocollabora:mainfrom
Conversation
Collaborator
|
Thanks for opening the PR! taking a look into it this week |
There was a problem hiding this comment.
Pull request overview
Adds a “reset transcript” control message to the existing WebSocket session so clients can start a fresh transcription without disconnecting/reconnecting.
Changes:
- Server: parse a JSON control frame (
{"action": "RESET_TRANSCRIPT"}) from the WebSocket receive loop and trigger a per-client reset. - Backend: add
ServeClientBase.reset_transcript()plus aTRANSCRIPT_RESETacknowledgment message back to the client. - Client + tests: add
Client.reset_transcript()and basic unit tests for reset + ack handling.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
whisper_live/server.py |
Adds control-frame parsing and a “RESET” sentinel path to keep the receive loop running. |
whisper_live/client.py |
Adds client-side reset API and logs server acknowledgment. |
whisper_live/backend/base.py |
Introduces server-side transcript/audio state reset and sends TRANSCRIPT_RESET ack. |
tests/test_server.py |
Adds unit tests for ServeClientBase.reset_transcript(). |
tests/test_client.py |
Adds tests for handling TRANSCRIPT_RESET ack and client reset behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| client.reset_transcript() | ||
| return "RESET" | ||
| except (UnicodeDecodeError, json.JSONDecodeError, ValueError): | ||
| pass # Not a JSON control frame; treat as audio bytes |
Comment on lines
309
to
+322
| if frame_data == b"END_OF_AUDIO": | ||
| return False | ||
| # Handle JSON control frames (sent as text or bytes that decode to JSON) | ||
| if isinstance(frame_data, (str, bytes)): | ||
| try: | ||
| decoded = frame_data if isinstance(frame_data, str) else frame_data.decode("utf-8") | ||
| control = json.loads(decoded) | ||
| if control.get("action") == "RESET_TRANSCRIPT": | ||
| client = self.client_manager.get_client(websocket) | ||
| if client: | ||
| client.reset_transcript() | ||
| return "RESET" | ||
| except (UnicodeDecodeError, json.JSONDecodeError, ValueError): | ||
| pass # Not a JSON control frame; treat as audio bytes |
| client.reset_transcript() | ||
| return "RESET" | ||
| except (UnicodeDecodeError, json.JSONDecodeError, ValueError): | ||
| pass # Not a JSON control frame; treat as audio bytes |
| self.end_time_for_same_output = None | ||
| self.frames_np = None | ||
| self.frames_offset = 0.0 | ||
| self.timestamp_offset = 0.0 |
Comment on lines
+273
to
+282
| with self.lock: | ||
| self.transcript = [] | ||
| self.text = [] | ||
| self.current_out = '' | ||
| self.prev_out = '' | ||
| self.same_output_count = 0 | ||
| self.end_time_for_same_output = None | ||
| self.frames_np = None | ||
| self.frames_offset = 0.0 | ||
| self.timestamp_offset = 0.0 |
| self.prev_out = '' | ||
| self.same_output_count = 0 | ||
| self.end_time_for_same_output = None | ||
| self.frames_np = None |
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.
Hey,
One have to disconnect or reconnect to reset the transcript. I needed a feature to reset the transcript on already connected session. Hence, I added this feature. I hope a lot of people might require this feature who could be building voice2voice agents. Each query needs to be a fresh session.
I vibecoded some parts but verified it manually and everything is fine and it works fine too.
This is not just for a show-off contribution, this is what I needed in my application and I wanted to avoid changing source code each time I am building any new application with the same need.
I'll be glad to receive any constructive criticism.