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

Add support to additional platforms #4

Merged
merged 23 commits into from
Feb 6, 2023
Merged

Conversation

JeisonSanches
Copy link
Collaborator

@JeisonSanches JeisonSanches commented Jan 30, 2023

Well... there is a lot of changes:

  • transform into a plugin
  • handles the compilation of the dynamic library on each platform
  • refactor the bindings following the standards used in ffi projects
  • add a c callback from dart
  • update the pure-dart example (inside bin)

And as a consequence of all the above, it makes the code portable for other additional platforms (macOS and iOS) and also improves the use on the other already supported ones (without the need for a binary explicitly included in the project).

As specified in the README file, I tested it on the following devices/platforms:

  • Windows 11 Pro 22H2 (22621.1105)
    CPU: AMD Ryzen 3600
    Ram: 16gb

  • Android 13
    CPU: Snapdragon 730
    Ram: 4gb

  • Pixel 3a API 33 Android x64 emulator

At the moment, I am not able to test it on macOS, iOS, and Linux, but it should work (it may need some minor tweaking).

Well, that's basically it. Thanks for coming up with the idea of migrating the code to dart and doing the initial setup!

I hope to be able to continue to contribute :)

@azkadev
Copy link
Owner

azkadev commented Jan 31, 2023

Thank you very much for wanting to contribute a lot, but sorry I can't accept this because you made my library only run on the client side (Flutter App)

@azkadev
Copy link
Owner

azkadev commented Jan 31, 2023

@JeisonSanches

Can you help me?
I tried your project it worked but only for android, I tried to build for the windows platform, and linux didn't work

@JeisonSanches
Copy link
Collaborator Author

Thank you very much for wanting to contribute a lot, but sorry I can't accept this because you made my library only run on the client side (Flutter App)

Currently, we don't have a way to have a package like this one to work seamleslly for both Dart and Flutter.
But I liked the idea (as you did) to split in two different packages: whisper_dart and whisper_flutter. That is exactly what I was going to suggest.

@JeisonSanches

Can you help me? I tried your project it worked but only for android, I tried to build for the windows platform, and linux didn't work

I can try. Could you share the build errors you got as well as the details of your environment?

@JeisonSanches JeisonSanches self-assigned this Jan 31, 2023
@azkadev
Copy link
Owner

azkadev commented Feb 1, 2023

Thank you very much for wanting to contribute a lot, but sorry I can't accept this because you made my library only run on the client side (Flutter App)

Currently, we don't have a way to have a package like this one to work seamleslly for both Dart and Flutter. But I liked the idea (as you did) to split in two different packages: whisper_dart and whisper_flutter. That is exactly what I was going to suggest.

@JeisonSanches
Can you help me? I tried your project it worked but only for android, I tried to build for the windows platform, and linux didn't work

I can try. Could you share the build errors you got as well as the details of your environment?

I tried to compile on linux it shows an error like this
command: flutter build linux --release -v

---
[        ] FAILED: plugins/whisper_flutter/shared/libwhisper.so 
[        ] : && /usr/bin/clang++ -fPIC -std=c++2a -O3 -DNDEBUG   -shared -Wl,-soname,libwhisper.so -o plugins/whisper_flutter/shared/libwhisper.so plugins/whisper_flutter/shared/CMakeFiles/whisper_flutter.dir/main.cpp.o
plugins/whisper_flutter/shared/libwhisper.a  plugins/whisper_flutter/shared/libggml.a && :
[        ] /usr/bin/ld: plugins/whisper_flutter/shared/libwhisper.a(whisper.cpp.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
[        ] /usr/bin/ld: plugins/whisper_flutter/shared/libggml.a(ggml.c.o): relocation R_X86_64_32S against `.bss' can not be used when making a shared object; recompile with -fPIC
[        ] clang: error: linker command failed with exit code 1 (use -v to see invocation)

---- 
[        ] ninja: build stopped: subcommand failed.
[  +10 ms] Building Linux application... (completed in 31.2s)
[        ] "flutter linux" took 34,237ms.
[   +3 ms] Build process failed
[        ] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      _runBuild (package:flutter_tools/src/linux/build_linux.dart:183:5)
           <asynchronous suspension>
           #2      buildLinux (package:flutter_tools/src/linux/build_linux.dart:76:5)
           <asynchronous suspension>
           #3      BuildLinuxCommand.runCommand (package:flutter_tools/src/commands/build_linux.dart:86:5)
           <asynchronous suspension>
           #4      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1257:27)
           <asynchronous suspension>
           #5      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #6      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:283:9)
           <asynchronous suspension>
           #8      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #9      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
           <asynchronous suspension>
           #10     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:64:9)
           <asynchronous suspension>
           #11     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #12     main (package:flutter_tools/executable.dart:91:3)
           <asynchronous suspension>
           

i don't have much experience in cpp and cmake languages

@JeisonSanches
Copy link
Collaborator Author

JeisonSanches commented Feb 1, 2023

@azkadev Could you try it again adding -fPIC to CMAKE_CXX_FLAGS in the sr/CMakeLists.txt file? Also, before you try to build again run:

sudo make uninstall
sudo make clean

@JeisonSanches
Copy link
Collaborator Author

JeisonSanches commented Feb 5, 2023

@azkadev Could you try it again adding -fPIC to CMAKE_CXX_FLAGS in the sr/CMakeLists.txt file? Also, before you try to build again run:

sudo make uninstall
sudo make clean

@azkadev Did you get success with it?

@azkadev
Copy link
Owner

azkadev commented Feb 5, 2023

@azkadev Could you try it again adding -fPIC to CMAKE_CXX_FLAGS in the sr/CMakeLists.txt file? Also, before you try to build again run:

sudo make uninstall
sudo make clean

Still can't, the same error appears, maybe if you don't mind + have time please make another pull request, sorry I bothered you because I don't really understand cpp + compile cmake

Sorry, my English is bad

@JeisonSanches
Copy link
Collaborator Author

JeisonSanches commented Feb 5, 2023

Still can't, the same error appears, maybe if you don't mind + have time please make another pull request, sorry I bothered you because I don't really understand cpp + compile cmake

Sorry, my English is bad

@azkadev Don't worry, mate.
Also, I fixed the error in my latest commits: now I'm able to build the project with no erros using a Ubuntu VM. Give it a try :)

@azkadev azkadev merged commit 0f1a9c7 into azkadev:main Feb 6, 2023
@azkadev
Copy link
Owner

azkadev commented Feb 6, 2023

Thank you very much for helping me, now thanks to you my library can run on various platforms

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

Successfully merging this pull request may close these issues.

2 participants