Skip to content

Commit 8728704

Browse files
Fix runner data buffer (#25)
* make sure pyaudio is installed * look for 0x0 in the end of the chunk
1 parent 66ad003 commit 8728704

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

edge_impulse_linux/runner.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,14 @@ def send_msg(self, msg):
8787

8888
t_sent_msg = now()
8989

90-
# i'm not sure if this is right, we should switch to async i/o for this like in Node
91-
# I think that would perform better
92-
data = self._client.recv(1 * 1024 * 1024)
90+
data = b""
91+
while True:
92+
chunk = self._client.recv(1024)
93+
# end chunk has \x00 in the end
94+
if chunk[-1] == 0:
95+
data = data + chunk[:-1]
96+
break
97+
data = data + chunk
9398

9499
t_received_msg = now()
95100

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ numpy>=1.19
22
PyAudio==0.2.11
33
psutil>=5.8.0
44
edge_impulse_linux
5+
six==1.16.0

setup.cfg

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,4 @@ classifiers =
1616
[options]
1717
packages = find:
1818
python_requires = >=3.6
19-
install_requires =
20-
numpy>=1.19
21-
psutil>=5.8.0
19+
install_requires = file: requirements.txt

0 commit comments

Comments
 (0)