Skip to content

Commit

Permalink
Use cached instance
Browse files Browse the repository at this point in the history
  • Loading branch information
jhj0517 committed Nov 15, 2024
1 parent 77215a0 commit b82078a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions backend/vad/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
)
Expand Down

0 comments on commit b82078a

Please sign in to comment.