mirror of
https://github.com/wahyd4/links.git
synced 2026-08-09 05:06:16 +10:00
fix(jbot): replace WebSocketApp.send_binary with ws.send(data, OPCODE_BINARY)
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>
This commit is contained in:
+5
-4
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user