Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is org.k2fsa.sherpa.onnx v1.10.17 supporting Android Xamarin? #1241

Open
EvanParallax opened this issue Aug 9, 2024 · 3 comments
Open

Is org.k2fsa.sherpa.onnx v1.10.17 supporting Android Xamarin? #1241

EvanParallax opened this issue Aug 9, 2024 · 3 comments

Comments

@EvanParallax
Copy link

Hi there!

I'm trying to embed sherpa in an android application using c# xamarin. org.k2fsa.sherpa.onnx v1.10.17 package works well on windows and linux. On Android there is a problem with creating OnlineRecognizer. While importing libsherpa-onnx-c-api.so I am getting DllNotFoundException. Using dlimport and dlerror, I found out that the error was in importing the transitive dependency libpthread.so.0. As far as I know there is no libpthread.so.0 in android, hence this libsherpa-onnx-c-api.so is not android oriented.
dlerror output - "dlopen failed: library "libpthread.so.0" not found: needed by /data/app/~~roWPFky3a7zFKDoAAw0VVA==/Dictation.Client-m1pLIjGpo753L8FT3uZF5Q==/lib/x86_64/libsherpa-onnx-c-api .so in namespace clns-6"
I tried to write a minimal application in flutter - it works. I took libsherpa-onnx-c-api.so from this build and linked it to my project, but it didn't work.
Will org.k2fsa.sherpa.onnx package support xamarin in the future?
Can you give instructions on how to link the required libsherpa-onnx-c-api.so assembly when building the nuget-package for xamarin from sources?

@csukuangfj
Copy link
Collaborator

please find our sherpa_onnx package on pub.dev for flutter.

@csukuangfj
Copy link
Collaborator

I tried to write a minimal application in flutter - it works. I took libsherpa-onnx-c-api.so from this build and linked it to my project, but it didn't work.

Please describe this step in detail

Also, please post all of the error logs

@EvanParallax
Copy link
Author

EvanParallax commented Aug 22, 2024

hello! here steps:

  1. Build working flutter example from your repo and extract libsherpa-onnx-c-api.so from the build
  2. Link extracted libsherpa-onnx-c-api.so to c# xamarin app
  3. Call OnlineRecognizer's constructor in runtime
  4. OnlineRecognizer's constructor throws managed c# exception DllNotFoundEception.

But real error examined via dlimport/dlerror is "dlopen failed: library "libpthread.so.0" not found: needed by /data/app/~~roWPFky3a7zFKDoAAw0VVA==/Dictation.Client-m1pLIjGpo753L8FT3uZF5Q==/lib/x86_64/libsherpa-onnx-c-api .so in namespace clns-6". So it can't import libsherpa-onnx-c-api .so because of importing transitive dependency "libpthread.so.0". dlerror output and c# exception stacktrace are all my error logs (:
"libpthread.so.0" is not present in android OS. I think step 2 doesn't work and it links "libsherpa-onnx-c-api.so" from nuget package but not from flutter build.

So my main question is how to link "libsherpa-onnx-c-api.so" from flutter build to nuget package for c# if i wanna build package from source via your scripts?

Today I got the idea to link "libsherpa-onnx-c-api.so" from flutter build with a different name and imort via custom import resolver, but dunno if that works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants