Skip to content

Commit fbca847

Browse files
author
litongjava
committed
modified client
1 parent 95c987d commit fbca847

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

client/readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ pip install websockets
55
```
66
```shell script
77
python client\websocket_client.py --server_ip 192.168.3.7 --port 8090 --wavfile samples/jfk.wav
8+
```
9+
only save audio
10+
```shell script
11+
python client\websocket_client.py --server_ip 192.168.3.7 --port 8090 --endpoint /streaming/save --wavfile samples/jfk.wav
812
```

client/websocket_client.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,13 @@ async def run(self, wavfile_path: str):
142142
for chunk_data in self.read_wave(wavfile_path):
143143
await ws.send(chunk_data.tobytes())
144144
msg = await ws.recv()
145-
msg = json.loads(msg)
146-
self.logger.info("client receive msg={}".format(msg))
145+
if msg:
146+
try:
147+
parsed_msg = json.loads(msg)
148+
self.logger.info("client receive msg={}".format(parsed_msg))
149+
except Exception as e:
150+
self.logger.error("Unexpected error: {}".format(e))
151+
147152
# 4. we must send finished signal to the server
148153
audio_info = json.dumps(
149154
{

0 commit comments

Comments
 (0)