

bugfix
@9bf89543df52dbb2be03828a9099255a2339a5d3
--- whisper_online_server.py
+++ whisper_online_server.py
... | ... | @@ -130,21 +130,28 @@ |
130 | 130 |
|
131 | 131 |
self.last_end = None |
132 | 132 |
|
133 |
+ self.is_first = True |
|
134 |
+ |
|
133 | 135 |
def receive_audio_chunk(self): |
134 | 136 |
# receive all audio that is available by this time |
135 | 137 |
# blocks operation if less than self.min_chunk seconds is available |
136 | 138 |
# unblocks if connection is closed or a chunk is available |
137 | 139 |
out = [] |
138 |
- while sum(len(x) for x in out) < self.min_chunk*SAMPLING_RATE: |
|
140 |
+ minlimit = self.min_chunk*SAMPLING_RATE |
|
141 |
+ while sum(len(x) for x in out) < minlimit: |
|
139 | 142 |
raw_bytes = self.connection.non_blocking_receive_audio() |
140 |
- print("received audio:",len(raw_bytes), "bytes", raw_bytes[:10]) |
|
141 | 143 |
if not raw_bytes: |
142 | 144 |
break |
145 |
+ print("received audio:",len(raw_bytes), "bytes", raw_bytes[:10]) |
|
143 | 146 |
sf = soundfile.SoundFile(io.BytesIO(raw_bytes), channels=1,endian="LITTLE",samplerate=SAMPLING_RATE, subtype="PCM_16",format="RAW") |
144 | 147 |
audio, _ = librosa.load(sf,sr=SAMPLING_RATE) |
145 | 148 |
out.append(audio) |
146 | 149 |
if not out: |
147 | 150 |
return None |
151 |
+ conc = np.concatenate(out) |
|
152 |
+ if self.is_first and len(conc) < minlimit: |
|
153 |
+ return None |
|
154 |
+ self.is_first = False |
|
148 | 155 |
return np.concatenate(out) |
149 | 156 |
|
150 | 157 |
def format_output_transcript(self,o): |
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?