alphacep / vosk-flutter

Apache License 2.0
51 stars 40 forks source link

macOS support #13

Open sergsavchuk opened 1 year ago

sergsavchuk commented 1 year ago

I tried to use libvosk.dylib from vosk-0.3.45 and got an error:

Building macOS application...
dyld[1236]: Library not loaded: 'libvosk.dylib'
  Referenced from: '/Users/mac/projects/flutter/vosk-flutter/example/build/macos/Build/Products/Debug/vosk_flutter_example.app/Contents/MacOS/vosk_flutter_example'
  Reason: tried: 'libvosk.dylib' (no such file), '/usr/local/lib/libvosk.dylib' (no such file), '/usr/lib/libvosk.dylib' (no such file), '/Users/mac/projects/flutter/vosk-flutter/example/libvosk.dylib' (no such file), '/usr/local/lib/libvosk.dylib' (no such file), '/usr/lib/libvosk.dylib' (no such file)

After a little investigation, I found that libvosk.dylib does have a non-rpath reference inside, which is causing the problem:

mac@Mac-mini-Mac Libraries % otool -L libvosk.dylib 
libvosk.dylib:
        libvosk.dylib (compatibility version 0.0.0, current version 0.0.0) # <- this one
        /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)

But I'm not much in macOS and CMake, so would appreciate any help in compiling the voks-api with RPATH enabled 🙏

sergsavchuk commented 1 year ago

P. S. I've already tried to modify libvosk.dylib using install_name_tool but got stuck with https://github.com/pyinstaller/pyinstaller/wiki/Recipe-OSX-Code-Signing#pyinstaller-fix-implementation

nshmyrev commented 1 year ago

It is not about dylib itself, I believe dylib just have to be in the flutter package where linker finds it

sergsavchuk commented 1 year ago

It is not about dylib itself, I believe dylib just have to be in the flutter package where linker finds it

Actually, it's already there(it's placed to Frameworks during build): image but linker tries to find it in the project root. And you gave me an idea - we can just create a symlink in the project root as a workaround 🤔

P. S. It looks like there is wrong version of the libvosk.dylib inside the https://repo1.maven.org/maven2/com/alphacephei/vosk/0.3.45/vosk-0.3.45.jar

00:46 +5 -1: Recognizer Constructor grammar and #setGrammar give same result [E]                                                                                                                                                       
  Invalid argument(s): Failed to lookup symbol 'vosk_recognizer_set_grm': dlsym(0x2020df5a0, vosk_recognizer_set_grm): symbol not found
nshmyrev commented 1 year ago

Yes, we need to rebuild it eventually, see https://github.com/alphacep/vosk-api/issues/681

nshmyrev commented 1 year ago

And we can package libvosk into framework too

moham96 commented 1 year ago

Can this be implemented please