Allow partial transcription when streaming
This commit is contained in:
parent
db2b6d956b
commit
72347d5d47
@ -62,6 +62,7 @@ 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]
|
||||||
|
try:
|
||||||
block_inference = self.buffer_to_text(block)
|
block_inference = self.buffer_to_text(block)
|
||||||
transcript += block_inference.transcript + " "
|
transcript += block_inference.transcript + " "
|
||||||
processing_time += block_inference.processing_time_sec
|
processing_time += block_inference.processing_time_sec
|
||||||
@ -70,6 +71,9 @@ class Inference:
|
|||||||
confidence = block_inference.confidence_score
|
confidence = block_inference.confidence_score
|
||||||
else:
|
else:
|
||||||
confidence *= block_inference.confidence_score
|
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