new buffer format
Browse files
src/whisper_streaming/online_asr.py
CHANGED
@@ -168,7 +168,7 @@ class OnlineASRProcessor:
|
|
168 |
"""
|
169 |
Get the unvalidated buffer in string format.
|
170 |
"""
|
171 |
-
return self.concatenate_tokens(self.transcript_buffer.buffer)
|
172 |
|
173 |
|
174 |
def process_iter(self) -> Transcript:
|
|
|
168 |
"""
|
169 |
Get the unvalidated buffer in string format.
|
170 |
"""
|
171 |
+
return self.concatenate_tokens(self.transcript_buffer.buffer)
|
172 |
|
173 |
|
174 |
def process_iter(self) -> Transcript:
|
whisper_fastapi_online_server.py
CHANGED
@@ -186,7 +186,6 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
186 |
if not chunk:
|
187 |
logger.info("FFmpeg stdout closed.")
|
188 |
break
|
189 |
-
|
190 |
pcm_buffer.extend(chunk)
|
191 |
if len(pcm_buffer) >= BYTES_PER_SEC:
|
192 |
if len(pcm_buffer) > MAX_BYTES_PER_SEC:
|
@@ -207,7 +206,9 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
207 |
new_tokens = online.process_iter()
|
208 |
tokens.extend(new_tokens)
|
209 |
full_transcription += sep.join([t.text for t in new_tokens])
|
210 |
-
|
|
|
|
|
211 |
if buffer in full_transcription: # With VAC, the buffer is not updated until the next chunk is processed
|
212 |
buffer = ""
|
213 |
else:
|
@@ -253,6 +254,7 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
253 |
lines[-1]["diff"] = round(token.end - last_end_diarized, 2)
|
254 |
|
255 |
response = {"lines": lines, "buffer": buffer}
|
|
|
256 |
await websocket.send_json(response)
|
257 |
|
258 |
except Exception as e:
|
|
|
186 |
if not chunk:
|
187 |
logger.info("FFmpeg stdout closed.")
|
188 |
break
|
|
|
189 |
pcm_buffer.extend(chunk)
|
190 |
if len(pcm_buffer) >= BYTES_PER_SEC:
|
191 |
if len(pcm_buffer) > MAX_BYTES_PER_SEC:
|
|
|
206 |
new_tokens = online.process_iter()
|
207 |
tokens.extend(new_tokens)
|
208 |
full_transcription += sep.join([t.text for t in new_tokens])
|
209 |
+
_buffer = online.get_buffer()
|
210 |
+
buffer = _buffer.text
|
211 |
+
end_buffer = _buffer.end if _buffer.end else tokens[-1].end if tokens else 0
|
212 |
if buffer in full_transcription: # With VAC, the buffer is not updated until the next chunk is processed
|
213 |
buffer = ""
|
214 |
else:
|
|
|
254 |
lines[-1]["diff"] = round(token.end - last_end_diarized, 2)
|
255 |
|
256 |
response = {"lines": lines, "buffer": buffer}
|
257 |
+
# response = {"lines": lines, "buffer": buffer, "time_buffer_transcription": time() + beg_loop - end_buffer, "time_buffer_diarization": time() + beg_loop - end_attributed_speaker}
|
258 |
await websocket.send_json(response)
|
259 |
|
260 |
except Exception as e:
|