Allow partial transcription when streaming
This commit is contained in:
parent
db2b6d956b
commit
72347d5d47
@ -62,14 +62,18 @@ class Inference:
|
|||||||
for block in stream:
|
for block in stream:
|
||||||
if len(block.shape) > 1:
|
if len(block.shape) > 1:
|
||||||
block = speech[:, 0] + speech[:, 1]
|
block = speech[:, 0] + speech[:, 1]
|
||||||
block_inference = self.buffer_to_text(block)
|
try:
|
||||||
transcript += block_inference.transcript + " "
|
block_inference = self.buffer_to_text(block)
|
||||||
processing_time += block_inference.processing_time_sec
|
transcript += block_inference.transcript + " "
|
||||||
if block_inference.confidence_score is not None:
|
processing_time += block_inference.processing_time_sec
|
||||||
if confidence is None:
|
if block_inference.confidence_score is not None:
|
||||||
confidence = block_inference.confidence_score
|
if confidence is None:
|
||||||
else:
|
confidence = block_inference.confidence_score
|
||||||
confidence *= block_inference.confidence_score
|
else:
|
||||||
|
confidence *= block_inference.confidence_score
|
||||||
|
except torch.OutOfMemoryError as e:
|
||||||
|
print(e)
|
||||||
|
break
|
||||||
return InferredTranscript(transcript.strip(), confidence, processing_time)
|
return InferredTranscript(transcript.strip(), confidence, processing_time)
|
||||||
|
|
||||||
def file_to_text(self, audio_file: typing.BinaryIO) -> InferredTranscript:
|
def file_to_text(self, audio_file: typing.BinaryIO) -> InferredTranscript:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user