Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix healthcheck and streaming with whisper #59

Open
wants to merge 16 commits into
base: next
Choose a base branch
from

Conversation

AudranBert
Copy link
Member

@AudranBert AudranBert commented Jan 7, 2025

This PR aims at fixing #49 #47 and #58 by:

  • Fix the healthcheck for the websocket mode
  • Fix healthcheck for the http mode (by adding curl to the docker images)
  • Fix partial and final for streaming with Whisper
  • Asynchronous transcription for streaming (not blocking packet reception)
  • Remove http+ENABLE_STREAMING for Whisper. It will redirect to websocket mode
  • Update the doc

What remains to be done:

  • More testing
  • Improve asynchronous transcription
  • Improve doc

healthcheck.sh Outdated Show resolved Hide resolved
@damienlaine damienlaine self-requested a review January 8, 2025 16:04
healthcheck.sh Outdated Show resolved Hide resolved
text = ""
partial = None
async with websockets.connect(ws_api) as websocket:
duration = 0
async with websockets.connect(ws_api, ping_interval=None, ping_timeout=None) as websocket:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping_interval / ping timeout : is that related to TCP breaks (HTTP WS keepAlive) ? Check comment below on handling only ConnectionClosedOK.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is to avoid closing websocket when it is not wanted. When testing, if I did not send any messages for a long time, the websocket closed by itself. By disabling the ping it doesn't close anymore.

logger.debug(f"??? {message}")
except asyncio.CancelledError:
logger.debug("Message processing thread stopped as websocket was closed.")
except websockets.exceptions.ConnectionClosedOK:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, only ConnectionClosedOK is handled to cancel the websocket. Please review whether other exceptions could occur in this context. For example, a TCP RST might trigger a ConnectionClosed event, similar to how WebSocketDisconnect is handled in FastAPI.

Additionally, a finally block might be missing to handle unexpected exceptions and actively close the context for the current socket.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case of that script, that is supposed to be just for testing the streaming locally I'm not sure if we can encounter other errors. I will add a finally to close the websocket and try to see if something else can be triggered.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok,
Check actual implementation in the real Websocket server to ensure corner-cases are well handled please.

websocket/healthcheck.py Outdated Show resolved Hide resolved
@AudranBert AudranBert requested a review from Jeronymous January 14, 2025 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants