Skip to content

Commit

Permalink
Better search for Windows dlls
Browse files Browse the repository at this point in the history
  • Loading branch information
nshmyrev committed Feb 12, 2021
1 parent 948c8c7 commit d917af2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ def get_tag(self):

setuptools.setup(
name="vosk",
version="0.3.18",
version="0.3.21",
author="Alpha Cephei Inc",
author_email="contact@alphacephei.com",
description="Offline open source speech recognition API based on Kaldi and Vosk",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/alphacep/vosk-api",
packages=setuptools.find_packages(),
package_data = {'vosk': ['*.so', '*.dll']},
package_data = {'vosk': ['*.so', '*.dll', '*.dyld']},
include_package_data=True,
classifiers=[
'Programming Language :: Python :: 3',
Expand Down
10 changes: 7 additions & 3 deletions python/vosk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
from .vosk_cffi import ffi as _ffi

def open_dll():
dlldir = os.path.abspath(os.path.dirname(__file__))
if sys.platform == 'win32':
os.environ["PATH"] += os.pathsep + os.path.dirname(__file__)
# 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("libvosk.dll")
elif sys.platform == 'linux':
return _ffi.dlopen(os.path.dirname(__file__) + "/libvosk.so")
return _ffi.dlopen(os.path.join(dlldir, "libvosk.so"))
elif sys.platform == 'darwin':
return _ffi.dlopen(os.path.dirname(__file__) + "/libvosk.dyld")
return _ffi.dlopen(os.path.join(dlldir, "libvosk.dyld"))
else:
raise TypeError("Unsupported platform")

Expand Down

0 comments on commit d917af2

Please sign in to comment.