

increasing timestamps fixed
but the code needs to be simplified and cleaned before merging
@175c382b7b1663fdee6316f039426d4c93c27e44
--- whisper_online.py
+++ whisper_online.py
... | ... | @@ -235,16 +235,19 @@ |
235 | 235 |
|
236 | 236 |
self.buffer_trimming_way, self.buffer_trimming_sec = buffer_trimming |
237 | 237 |
|
238 |
- def init(self): |
|
238 |
+ def init(self, keep_offset=False): |
|
239 | 239 |
"""run this when starting or restarting processing""" |
240 | 240 |
self.audio_buffer = np.array([],dtype=np.float32) |
241 |
- self.buffer_time_offset = 0 |
|
242 |
- |
|
243 | 241 |
self.transcript_buffer = HypothesisBuffer(logfile=self.logfile) |
242 |
+ if not keep_offset: |
|
243 |
+ self.buffer_time_offset = 0 |
|
244 |
+ self.transcript_buffer.last_commited_time = 0 |
|
245 |
+ else: |
|
246 |
+ self.transcript_buffer.last_commited_time = self.buffer_time_offset |
|
247 |
+ |
|
244 | 248 |
self.commited = [] |
245 | 249 |
self.last_chunked_at = 0 |
246 | 250 |
|
247 |
- self.silence_iters = 0 |
|
248 | 251 |
|
249 | 252 |
def insert_audio_chunk(self, audio): |
250 | 253 |
self.audio_buffer = np.append(self.audio_buffer, audio) |
... | ... | @@ -400,6 +403,7 @@ |
400 | 403 |
o = self.transcript_buffer.complete() |
401 | 404 |
f = self.to_flush(o) |
402 | 405 |
print("last, noncommited:",f,file=self.logfile) |
406 |
+ self.buffer_time_offset += len(self.audio_buffer)/16000 |
|
403 | 407 |
return f |
404 | 408 |
|
405 | 409 |
|
--- whisper_online_vac.py
+++ whisper_online_vac.py
... | ... | @@ -45,7 +45,7 @@ |
45 | 45 |
|
46 | 46 |
def finish(self): |
47 | 47 |
ret = self.online.finish() |
48 |
- self.online.init() |
|
48 |
+ self.online.init(keep_offset=True) |
|
49 | 49 |
self.current_online_chunk_buffer_size = 0 |
50 | 50 |
return ret |
51 | 51 |
|
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?