From b82078a7a7bc6c472257177b4133416aeca8484e Mon Sep 17 00:00:00 2001 From: jhj0517 <97279763+jhj0517@users.noreply.github.com> Date: Sat, 16 Nov 2024 00:27:14 +0900 Subject: [PATCH] Use cached instance --- backend/vad/router.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/backend/vad/router.py b/backend/vad/router.py index 4c60114..adad881 100644 --- a/backend/vad/router.py +++ b/backend/vad/router.py @@ -13,6 +13,8 @@ from ..util.audio import read_audio from ..util.schemas import QueueResponse +vad_router = APIRouter() + @functools.lru_cache def init_vad_model() -> SileroVAD: @@ -21,15 +23,11 @@ def init_vad_model() -> SileroVAD: return inferencer -vad_router = APIRouter() -vad_inferencer = init_vad_model() - - async def run_vad( audio: np.ndarray, params: VadOptions ) -> List[Dict]: - audio, speech_chunks = vad_inferencer.run( + audio, speech_chunks = init_vad_model().run( audio=audio, vad_parameters=params )