From de9ca336d24115ec8b74ec312ac3782808ab6d86 Mon Sep 17 00:00:00 2001 From: boocmp Date: Mon, 19 Aug 2024 18:06:56 +0700 Subject: [PATCH] wav2vec2 backend + large + 6 workers. --- src/runners/audio_transcriber.py | 4 +--- src/stt_api.py | 4 +++- src/utils/ipc/messages.py | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/runners/audio_transcriber.py b/src/runners/audio_transcriber.py index d4379f1..7f54112 100644 --- a/src/runners/audio_transcriber.py +++ b/src/runners/audio_transcriber.py @@ -74,7 +74,6 @@ def add(self, word): ): self.transcription += word.word - """ class BatchableAudioTranscriber(bentoml.Runnable): SUPPORTED_RESOURCES = ("nvidia.com/gpu", "cpu") @@ -232,7 +231,6 @@ def transcribe_audio(self, inputs: list[BatchInput]) -> list[str]: for text in segments ] - """ from transformers import WhisperProcessor, WhisperForConditionalGeneration import torch @@ -300,4 +298,4 @@ def transcribe_audio(self, inputs: list[BatchInput]) -> list[str]: ) for text in segments ] -""" +""" \ No newline at end of file diff --git a/src/stt_api.py b/src/stt_api.py index 12315ad..bec5af7 100644 --- a/src/stt_api.py +++ b/src/stt_api.py @@ -70,7 +70,7 @@ async def handleUpstream( transciption = await runner_audio_transcriber.async_run( [BatchInput(audio=mic_data, lang=lang, pair=pair)] ) - process_time = datetime.now() - process_time + process_time = (datetime.now() - process_time).total_seconds() out = transciption[0] print( @@ -94,6 +94,7 @@ async def handleUpstream( out.merge_audio_time + out.transcribe_time + out.restore_time, + process_time, ) ) finally: @@ -133,6 +134,7 @@ async def handleStream(pair): "final": text.final, "buffer": text.buffer_len, "process_time": text.process_time, + "time": text.time, } ) except Exception as e: diff --git a/src/utils/ipc/messages.py b/src/utils/ipc/messages.py index 9b88d67..a290bf6 100644 --- a/src/utils/ipc/messages.py +++ b/src/utils/ipc/messages.py @@ -19,6 +19,7 @@ class Text(msgspec.Struct, tag=True): final: bool buffer_len: int = 0 process_time: float = 0 + time: float = 0 Request = Publish | Subscribe | Ready | Text