

fix bug in server
@29cc1753574664d030b503b7bb77af3b5ee75c1d
--- whisper_online_server.py
+++ whisper_online_server.py
... | ... | @@ -89,7 +89,7 @@ |
89 | 89 |
|
90 | 90 |
class Connection: |
91 | 91 |
'''it wraps conn object''' |
92 |
- PACKET_SIZE = 65536 |
|
92 |
+ PACKET_SIZE = 32000*5*60 # 5 minutes # was: 65536 |
|
93 | 93 |
|
94 | 94 |
def __init__(self, conn): |
95 | 95 |
self.conn = conn |
... | ... | @@ -109,8 +109,11 @@ |
109 | 109 |
return in_line |
110 | 110 |
|
111 | 111 |
def non_blocking_receive_audio(self): |
112 |
- r = self.conn.recv(self.PACKET_SIZE) |
|
113 |
- return r |
|
112 |
+ try: |
|
113 |
+ r = self.conn.recv(self.PACKET_SIZE) |
|
114 |
+ return r |
|
115 |
+ except ConnectionResetError: |
|
116 |
+ return None |
|
114 | 117 |
|
115 | 118 |
|
116 | 119 |
import io |
... | ... | @@ -134,8 +137,7 @@ |
134 | 137 |
out = [] |
135 | 138 |
while sum(len(x) for x in out) < self.min_chunk*SAMPLING_RATE: |
136 | 139 |
raw_bytes = self.connection.non_blocking_receive_audio() |
137 |
- print(raw_bytes[:10]) |
|
138 |
- print(len(raw_bytes)) |
|
140 |
+ print("received audio:",len(raw_bytes), "bytes", raw_bytes[:10]) |
|
139 | 141 |
if not raw_bytes: |
140 | 142 |
break |
141 | 143 |
sf = soundfile.SoundFile(io.BytesIO(raw_bytes), channels=1,endian="LITTLE",samplerate=SAMPLING_RATE, subtype="PCM_16",format="RAW") |
... | ... | @@ -203,7 +205,6 @@ |
203 | 205 |
# server loop |
204 | 206 |
|
205 | 207 |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: |
206 |
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
|
207 | 208 |
s.bind((args.host, args.port)) |
208 | 209 |
s.listen(1) |
209 | 210 |
logging.info('INFO: Listening on'+str((args.host, args.port))) |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?