0

I'm actually trying to import a package in the python shell but I get a shared object error

>>> from vosk import aligner
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ec2-user/voice_recog/vosk-api/python/vosk/__init__.py", line 21, in <module>
    _c = open_dll()
  File "/home/ec2-user/voice_recog/vosk-api/python/vosk/__init__.py", line 15, in open_dll
    return _ffi.dlopen(os.path.join(dlldir, "libvosk.so"))
OSError: cannot load library '/home/ec2-user/voice_recog/vosk-api/python/vosk/libvosk.so': /home/ec2-user/voice_recog/vosk-api/python/vosk/libvosk.so: cannot open shared object file: No such file or directory

Also the init.py file has these lines

def open_dll():
    dlldir = os.path.abspath(os.path.dirname(__file__))
    if sys.platform == 'win32':
        # We want to load dependencies too
        os.environ["PATH"] = dlldir + os.pathsep + os.environ['PATH']
        if hasattr(os, 'add_dll_directory'):
            os.add_dll_directory(dlldir)
        return _ffi.dlopen(os.path.join(dlldir, "libvosk.dll"))
    elif sys.platform == 'linux':
        return _ffi.dlopen(os.path.join(dlldir, "libvosk.so"))
    elif sys.platform == 'darwin':
        return _ffi.dlopen(os.path.join(dlldir, "libvosk.dyld"))
    else:
        raise TypeError("Unsupported platform")

_c = open_dll()

This is the directory I'm working on root directory

And this is the directory of the vosk package

vosk package trying to import

Vikram Vm
  • 13
  • 3

1 Answers1

0

The link file depending upon the OS has to be downloaded from https://github.com/alphacep/vosk-api/releases and has to be placed in the respective directory where the error occurs.

Vikram Vm
  • 13
  • 3
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 29 '22 at 19:43
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/31892493) – Emi OB Jun 01 '22 at 08:01