From 2d6d4b09fc32865522f8e904abb2d414b60abfb1 Mon Sep 17 00:00:00 2001 From: Junwei Zhao Date: Sun, 17 May 2026 12:07:21 +1000 Subject: [PATCH] fix(jbot): replace WebSocketApp.send_binary with ws.send(data, OPCODE_BINARY) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WebSocketApp callbacks receive the WebSocketApp object, not WebSocket. WebSocketApp has no send_binary() method — must use: ws.send(data, ws_module.ABNF.OPCODE_BINARY) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- jbot/views.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jbot/views.py b/jbot/views.py index d5b1f35..ac4cc95 100644 --- a/jbot/views.py +++ b/jbot/views.py @@ -311,19 +311,20 @@ def _do_asr(audio_bytes: bytes, mime_type: str = 'audio/webm') -> str: 'end_window_size': 800, }, }).encode() - ws.send_binary(_asr_pack(_ASR_MT_FULL_CLIENT, _FLAG_NO_SEQ, - _SER_JSON, _CMP_GZIP, gzip.compress(config))) + ws.send(_asr_pack(_ASR_MT_FULL_CLIENT, _FLAG_NO_SEQ, + _SER_JSON, _CMP_GZIP, gzip.compress(config)), + ws_module.ABNF.OPCODE_BINARY) CHUNK = 6400 pcm_data = pcm for off in range(0, len(pcm_data), CHUNK): chunk = pcm_data[off:off + CHUNK] is_last = (off + CHUNK >= len(pcm_data)) - ws.send_binary(_asr_pack( + ws.send(_asr_pack( _ASR_MT_AUDIO_ONLY, _FLAG_LAST_NO if is_last else _FLAG_NO_SEQ, _SER_NONE, _CMP_GZIP, gzip.compress(chunk), - )) + ), ws_module.ABNF.OPCODE_BINARY) def on_message(ws, data): try: