Add get_buffer method to retrieve unvalidated buffer in string format
This commit is contained in:
parent
788fe1c676
commit
15089c80fd
2 changed files with 17 additions and 7 deletions
|
|
@ -85,6 +85,7 @@ class HypothesisBuffer:
|
||||||
self.committed_in_buffer.pop(0)
|
self.committed_in_buffer.pop(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class OnlineASRProcessor:
|
class OnlineASRProcessor:
|
||||||
"""
|
"""
|
||||||
Processes incoming audio in a streaming fashion, calling the ASR system
|
Processes incoming audio in a streaming fashion, calling the ASR system
|
||||||
|
|
@ -163,6 +164,13 @@ class OnlineASRProcessor:
|
||||||
context_text = self.asr.sep.join(token.text for token in non_prompt_tokens)
|
context_text = self.asr.sep.join(token.text for token in non_prompt_tokens)
|
||||||
return self.asr.sep.join(prompt_list[::-1]), context_text
|
return self.asr.sep.join(prompt_list[::-1]), context_text
|
||||||
|
|
||||||
|
def get_buffer(self):
|
||||||
|
"""
|
||||||
|
Get the unvalidated buffer in string format.
|
||||||
|
"""
|
||||||
|
return self.concatenate_tokens(self.transcript_buffer.buffer).text
|
||||||
|
|
||||||
|
|
||||||
def process_iter(self) -> Transcript:
|
def process_iter(self) -> Transcript:
|
||||||
"""
|
"""
|
||||||
Processes the current audio buffer.
|
Processes the current audio buffer.
|
||||||
|
|
@ -414,3 +422,9 @@ class VACOnlineASRProcessor:
|
||||||
self.current_online_chunk_buffer_size = 0
|
self.current_online_chunk_buffer_size = 0
|
||||||
self.is_currently_final = False
|
self.is_currently_final = False
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def get_buffer(self):
|
||||||
|
"""
|
||||||
|
Get the unvalidated buffer in string format.
|
||||||
|
"""
|
||||||
|
return self.online.concatenate_tokens(self.online.transcript_buffer.buffer).text
|
||||||
|
|
|
||||||
|
|
@ -158,12 +158,8 @@ async def websocket_endpoint(websocket: WebSocket):
|
||||||
})
|
})
|
||||||
|
|
||||||
full_transcription += transcription.text
|
full_transcription += transcription.text
|
||||||
if args.vac:
|
buffer = online.get_buffer()
|
||||||
transcript = online.online.concatenate_tokens(online.online.transcript_buffer.buffer)
|
|
||||||
else:
|
|
||||||
transcript = online.concatenate_tokens(online.transcript_buffer.buffer)
|
|
||||||
|
|
||||||
buffer = transcript.text
|
|
||||||
if buffer in full_transcription: # With VAC, the buffer is not updated until the next chunk is processed
|
if buffer in full_transcription: # With VAC, the buffer is not updated until the next chunk is processed
|
||||||
buffer = ""
|
buffer = ""
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue