vosk-flutter icon indicating copy to clipboard operation
vosk-flutter copied to clipboard

macOS support

Open sergsavchuk opened this issue 1 year ago • 6 comments

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 avatar Apr 12 '23 08:04 sergsavchuk

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

sergsavchuk avatar Apr 12 '23 08:04 sergsavchuk

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

nshmyrev avatar Apr 12 '23 09:04 nshmyrev

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

sergsavchuk avatar Apr 12 '23 13:04 sergsavchuk

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

nshmyrev avatar Apr 12 '23 13:04 nshmyrev

And we can package libvosk into framework too

nshmyrev avatar Apr 12 '23 13:04 nshmyrev

Can this be implemented please

moham96 avatar Sep 09 '23 00:09 moham96