warmup base whisper when using simulstreaming
This commit is contained in:
parent
7fb8e66c01
commit
15c3df1cba
3 changed files with 10 additions and 6 deletions
|
|
@ -2,7 +2,7 @@ try:
|
|||
from whisperlivekit.whisper_streaming_custom.whisper_online import backend_factory
|
||||
from whisperlivekit.whisper_streaming_custom.online_asr import VACOnlineASRProcessor, OnlineASRProcessor
|
||||
except ImportError:
|
||||
from .whisper_streaming_custom.whisper_online import backend_factory, warmup_asr
|
||||
from .whisper_streaming_custom.whisper_online import backend_factory
|
||||
from .whisper_streaming_custom.online_asr import VACOnlineASRProcessor, OnlineASRProcessor
|
||||
from whisperlivekit.warmup import warmup_asr, warmup_online
|
||||
from argparse import Namespace
|
||||
|
|
@ -109,7 +109,7 @@ class TranscriptionEngine:
|
|||
|
||||
else:
|
||||
self.asr, self.tokenizer = backend_factory(self.args)
|
||||
warmup_asr(self.asr, self.args.warmup_file) #for simulstreaming, warmup should be done in the online class not here
|
||||
warmup_asr(self.asr, self.args.warmup_file) #for simulstreaming, warmup should be done in the online class not here
|
||||
|
||||
if self.args.diarization:
|
||||
from whisperlivekit.diarization.diarization_online import DiartDiarization
|
||||
|
|
@ -130,7 +130,7 @@ def online_factory(args, asr, tokenizer, logfile=sys.stderr):
|
|||
asr,
|
||||
logfile=logfile,
|
||||
)
|
||||
warmup_online(online, args.warmup_file)
|
||||
# warmup_online(online, args.warmup_file)
|
||||
elif args.vac:
|
||||
online = VACOnlineASRProcessor(
|
||||
args.min_chunk_size,
|
||||
|
|
|
|||
|
|
@ -125,8 +125,6 @@ class SimulStreamingOnlineProcessor:
|
|||
def warmup(self, audio, init_prompt=""):
|
||||
"""Warmup the SimulStreaming model."""
|
||||
try:
|
||||
if isinstance(audio, np.ndarray):
|
||||
audio = torch.from_numpy(audio).float()
|
||||
self.model.insert_audio(audio)
|
||||
self.model.infer(True)
|
||||
self.model.refresh_segment(complete=True)
|
||||
|
|
@ -217,3 +215,9 @@ class SimulStreamingASR():
|
|||
num_languages=self.model.model.num_languages,
|
||||
task="translate"
|
||||
)
|
||||
|
||||
def transcribe(self, audio):
|
||||
"""
|
||||
Only used for warmup. It's a direct whisper call, not a simulstreaming call
|
||||
"""
|
||||
self.whisper_model.transcribe(audio, language=self.original_language)
|
||||
|
|
@ -53,7 +53,7 @@ def warmup_asr(asr, warmup_file=None, timeout=5):
|
|||
Warmup the ASR model by transcribing a short audio file.
|
||||
"""
|
||||
audio = load_file(warmup_file=None, timeout=5)
|
||||
asr.warmup(audio)
|
||||
asr.transcribe(audio)
|
||||
logger.info("ASR model is warmed up")
|
||||
|
||||
def warmup_online(online, warmup_file=None, timeout=5):
|
||||
|
|
|
|||
Loading…
Reference in a new issue