alphacep / vosk-api

Offline speech recognition API for Android, iOS, Raspberry Pi and servers with Python, Java, C# and Node
Apache License 2.0
7.36k stars 1.04k forks source link

cannot importing libvosk.dll #1549

Open duran004 opened 3 months ago

duran004 commented 3 months ago

I can't load the vosk model and it doesn't give me an error. I did some editing to find the error.

def open_dll():
        try:
            dlldir = os.path.abspath(os.path.dirname(__file__))
            if sys.platform == "win32":
                # We want to load dependencies too
                print("importing vosk dll...1")
                os.environ["PATH"] = dlldir + os.pathsep + os.environ["PATH"]
                print("importing vosk dll...2")
                if hasattr(os, "add_dll_directory"):
                    print("importing vosk dll...3")
                    os.add_dll_directory(dlldir)
                    print("importing vosk dll...4")
                    print(os.path.join(dlldir, "libvosk.dll"))
                    e=_ffi.dlopen(os.path.join(dlldir, "libvosk.dll"))
                    print("importing vosk dll...5")
                return e
            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")
        except Exception as e:
            print(f"An error occurred: {e}")

the output is like this

importing vosk dll...1
importing vosk dll...2
importing vosk dll...3
importing vosk dll...4
C:\Users\dcyilmaz\AppData\Local\Programs\Python\Python312\Lib\site-packages\vosk\libvosk.dll

When I check the dll file, it exists in the directory image

nshmyrev commented 3 months ago

You can check with dependencywalker to see what is missing for the dll.

duran004 commented 3 months ago

You can check with dependencywalker to see what is missing for the dll.

When I try to open libvosk.dll with the library https://github.com/lucasg/Dependencies , I think it says they are missing. I don't quite understand. image

duran004 commented 3 months ago

Any ideas?

nshmyrev commented 3 months ago

Those ext ones are expected and not critical. You need to show whole window, not a small part.

duran004 commented 3 months ago

ofcourse image

image image image image image image

nshmyrev commented 2 months ago

Maybe you have 32-bit python and you installed 64-bit package