How to manually import a python package in Audio2Face Kit

Hey, I’m facing an issue where the convai python extension for omniverse uses a newer version of gprc and google.protobuf python packages than the ones installed in audio2face by default.

I pip install the specific version like this, and I have verified that they get installed correctly here: C:\Users\arajnish\AppData\Local\ov\data\Kit\Audio2Face\2023.2\pip3-envs

[python.pipapi]

requirements = [
    "requests",
    "scipy",
    "wavio",
    "sounddevice",
    "requests",
    "googleapis-common-protos",
    "grpcio==1.51.1",
    "grpcio-tools==1.51.1",
    "protobuf==4.21.10",
    "PyAudio==0.2.12",
    "pydub==0.25.1"
]

use_online_index = true
ignore_import_check = false

But omniverse always prefers to import modules from this location first which has an older version of both the the modules : C:\Users\arajnish\AppData\Local\ov\pkg\audio2face-2023.2.0\exts\omni.audio2face.player_deps\deps\py

If I run the same extension in the Code Kit it works fine as it doesn’t have these modules pre-installed.

How do I make Audio2Face manually import from C:\Users\arajnish\AppData\Local\ov\data\Kit\Audio2Face\2023.2\pip3-envs so that it works correctly.

I’ve tried multiple ways like:

  • copying the modules manually into the omni.audio2face.player_deps\deps\py folder and renaming it so that both the modules exist together in one folder
  • using importlib.util to import from the specific location but none of them seem to work, esp for google.protobuf when I try to import it like this:
from . import custom_import
protobuf = custom_import.importModule(custom_import.protobufPath, 'google.protobuf')

_builder = protobuf.internal.builder
_descriptor = protobuf.descriptor
_descriptor_pool = protobuf.descriptor_pool
_symbol_database = protobuf.symbol_database


import os, sys, importlib.util

def importModule(path, name):
    spec = importlib.util.spec_from_file_location(name, path)
    module = importlib.util.module_from_spec(spec)
    sys.modules[name] = module
    spec.loader.exec_module(module)
    return module

baseUserPath = os.environ.get('USERPROFILE', 'C:\\Users\\Default')
grpcPath = os.path.join(baseUserPath, 'AppData', 'Local', 'ov', 'data', 'Kit', 'Audio2Face', '2023.2', 'pip3-envs', 'default', 'grpc', '__init__.py')
protobufPath = os.path.join(baseUserPath, 'AppData', 'Local', 'ov', 'data', 'Kit', 'Audio2Face', '2023.2', 'pip3-envs', 'default', 'google', 'protobuf', '__init__.py')

Can someone please spare some time and help me out??