Skip to content

Make silero onnxruntime session shared #2050

Description

@erkamkavak

Problem Statement

Currently silero vad tries to load onnx file and create a new onnxruntime InferenceSession each time it is created. When there are multiple clients and pipeline tasks, a new onnxruntime session is created for each of these tasks.

model_name = "silero_vad.onnx"
package_path = "pipecat.audio.vad.data"
try:
import importlib_resources as impresources
model_file_path = str(impresources.files(package_path).joinpath(model_name))
except BaseException:
from importlib import resources as impresources
try:
with impresources.path(package_path, model_name) as f:
model_file_path = f
except BaseException:
model_file_path = str(impresources.files(package_path).joinpath(model_name))
self._model = SileroOnnxModel(model_file_path, force_onnx_cpu=True)

Proposed Solution

I think all silero vad analyzers could use a single onnxruntime session across different tasks. As far as I can see, there is no problem using a single onnxruntime session in silero vad(but I guess each silero vad analyzer should be specific to pipeline since it has a state inside)

Alternative Solutions

No response

Additional Context

No response

Would you be willing to help implement this feature?

  • Yes, I'd like to contribute
  • No, I'm just suggesting

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions