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

Fail when compiling Android library Libwhisper.a from sources #78

Open
Dan0398 opened this issue Mar 16, 2024 · 1 comment
Open

Fail when compiling Android library Libwhisper.a from sources #78

Dan0398 opened this issue Mar 16, 2024 · 1 comment
Labels
question Further information is requested

Comments

@Dan0398
Copy link

Dan0398 commented Mar 16, 2024

I cloned your repository and run from Win11 editor. It works awesome.
But when i built it for Android (Google Pixel 3a) it works very slow. Simple phrace 3 seconds length processed over 30 seconds.
Speedup feature throws an error (-1) even in editor.

Turning on more than 1 thread change processing time to 16 seconds. Better, but still not for production app.

But i saw how Whisper for android works in another repos:
https://www.youtube.com/watch?v=w9pohi9NQrg
This video is part of demo in this repo:
https://github.com/vilassn/whisper_android

Method that runs so slow in on Whisper side. As solution i selected to try to recompile a library with few arguments that can tweak perfomance.

What i tried to do:

  1. Cloned the original whisper.cpp repository, but 1.5.4 checkout

  2. In "CMakeLists.txt" i added few lines on top because it doesn't processes without it:

set(CMAKE_C_COMPILER_WORKS 1)
set(CMAKE_CXX_COMPILER_WORKS 1)
set(CMAKE_THREAD_LIBS_INIT "-lpthread")

  1. Run Cmake with this args:
    cmake -DCMAKE_TOOLCHAIN_FILE="E:\Programs\Unity\2022.3.10f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\build\cmake\android.toolchain.cmake"
    -DANDROID_ABI=arm64-v8a
    -DBUILD_SHARED_LIBS=OFF
    -DWHISPER_BUILD_TESTS=OFF
    -DWHISPER_BUILD_EXAMPLES=OFF
    -DANDROID_PLATFORM=29
    -DANDROID_NATIVE_API_LEVEL=29
    -DCMAKE_BUILD_TYPE=Release
    -G "MinGW Makefiles"
    -DCMAKE_MAKE_PROGRAM="E:\whisper\CMakeLists.txt"

  2. Run Makefile with Mingw32.

As result i got a "libwhisper.a" file. But it weight 1,43 MB, when your precompiled version weight 13,9 MB.
When i tried to build .apk file with mine library i got an error
"android error: undefined symbol: stdout" (and stderr).

What i does wrong?

Win 11, Unity 2022.3.10f1, CMake 3.29, MinGW 3.80.3.

@Macoron
Copy link
Owner

Macoron commented Mar 24, 2024

The easiest way to recompile whisper.cpp from source is to use Github Action. It uses ready-to-use instances, so you won't have any problems with build tools. You can create your own fork and run "Build C++" action there. Check readme for more info.

If you still struggle to recompile whisper.cpp on your local machine, maybe it worth trying to ask guys in original whisper.cpp repo. I never tried to build Android libs of whisper.cpp on Windows, so I won't be able to help what might be a problem.

As for making Android work faster, check #47. It is known problem with whisper.cpp, which wasn't addressed by original dev team yet.

@Macoron Macoron added the question Further information is requested label Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants