Skip to content

Commit

Permalink
dev(narugo): extract vad tools
Browse files Browse the repository at this point in the history
  • Loading branch information
narugo1992 committed Sep 1, 2024
1 parent cbb2f49 commit 86b22cf
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions zoo/silero/vad/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,18 @@
from typing import Callable, Optional

import numpy as np
import onnxruntime
from huggingface_hub import hf_hub_download
from tqdm import tqdm

from soundutils.data import Sound
from soundutils.utils import open_onnx_model

languages = ['ru', 'en', 'de', 'es']


class OnnxWrapper:
def __init__(self, path, force_onnx_cpu=False):

opts = onnxruntime.SessionOptions()
opts.inter_op_num_threads = 1
opts.intra_op_num_threads = 1

if force_onnx_cpu and 'CPUExecutionProvider' in onnxruntime.get_available_providers():
self.session = onnxruntime.InferenceSession(path, providers=['CPUExecutionProvider'], sess_options=opts)
else:
self.session = onnxruntime.InferenceSession(path, sess_options=opts)

def __init__(self, path):
self.session = open_onnx_model(path)
self._state = np.zeros((2, 1, 128), dtype=np.float32)
self._context = np.zeros(0, dtype=np.float32)
self._last_sr = 0
Expand Down

0 comments on commit 86b22cf

Please sign in to comment.