-
-
Notifications
You must be signed in to change notification settings - Fork 110
Description
How to reproduce:
1, start the server side
2, start the client side
3, press ctrl+C on the client side and restart the client side
Then the server side will hang. The client side will have no output and never ends by itself.
Btw, when a ctrl=C is pressed, an incomplete base64 string may be received on the server side,
so I catch the exception and return a dummy array data, otherwise there will error message like this:
File "/home/repo/diart/src/diart/utils.py", line 67, in decode_audio
byte_samples = base64.decodebytes(data.encode("utf-8"))
File "/home/miniforge3/envs/diart-spk/lib/python3.10/base64.py", line 562, in decodebytes
return binascii.a2b_base64(s)
Here is the code where I catch the exception and return the dummy data.
def decode_audio(data: Text) -> np.ndarray:
# Decode chunk encoded in base64
try:
byte_samples = base64.decodebytes(data.encode("utf-8"))
# Recover array from bytes
samples = np.frombuffer(byte_samples, dtype=np.float32)
return samples.reshape(1, -1)
except Exception:
print("Invalid base64 data")
return np.array([[0,0]])
The server side will still hang.