-
Notifications
You must be signed in to change notification settings - Fork 24
FileNotFoundError: Shared library with base name 'whisper' not found #9
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
Comments
Hi @DamienDabernat , thanks for the report! You have done everything right, it is actually a bug of locating the lib, currently the system is looking for a lib with *.dylib extension for macos systems but it is actually being created with the suffix *so, I will fix it and let you know. Int the meantime you can try doing import whisper_cpp_python.whisper_cpp as wc
wc._load_shared_library('whisper.so') And see if you can then use the module |
Hi, thanks for your reply! I didn't succeed in making this work with : import whisper_cpp_python.whisper_cpp as wc
wc._load_shared_library('whisper.so') But with your help, I was able to make some advancement. I have cloned this repository and in the file # Specify the base name of the shared library to load
_lib_base_name = "libwhisper" And : # Specify the base name of the shared library to load
elif sys.platform == "darwin":
lib_ext = ".dylib" With this done, I was nearly capable of importing the correct lib, but the script failed at the import of I was capable of fixing this by installing the lib as follows :
This worked. Then, when I was trying to transcribe some audio, I'm facing this error :
So, I managed to install python 3.9 : # Create new environment
conda create -n tensorflow python=3.9
conda activate tensorflow
# Install tensorflow + scikit-learn
conda install -c apple tensorflow-deps
python -m pip install tensorflow-macos
python -m pip install tensorflow-metal
python -m pip install scikit-learn
# Check import works
python -c "import sklearn" Then re-install whisper_init_from_file_no_state: loading model from './vendor/whisper.cpp/models/ggml-small.bin'
whisper_model_load: loading model
whisper_model_load: n_vocab = 51865
whisper_model_load: n_audio_ctx = 1500
whisper_model_load: n_audio_state = 768
whisper_model_load: n_audio_head = 12
whisper_model_load: n_audio_layer = 12
whisper_model_load: n_text_ctx = 448
whisper_model_load: n_text_state = 768
whisper_model_load: n_text_head = 12
whisper_model_load: n_text_layer = 12
whisper_model_load: n_mels = 80
whisper_model_load: ftype = 1
whisper_model_load: type = 3
whisper_model_load: mem required = 743.00 MB (+ 16.00 MB per decoder)
whisper_model_load: adding 1608 extra tokens
whisper_model_load: model ctx = 464.56 MB
whisper_model_load: model size = 464.44 MB
whisper_init_state: kv self size = 15.75 MB
whisper_init_state: kv cross size = 52.73 MB
Exception ignored from cffi callback <function SoundFile._init_virtual_io.<locals>.vio_read at 0x287d13b80>:
Traceback (most recent call last):
File "/Users/damien/miniconda3/envs/tensorflow/lib/python3.9/site-packages/soundfile.py", line 1248, in vio_read
data = file.read(count)
File "/Users/damien/miniconda3/envs/tensorflow/lib/python3.9/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 24: invalid start byte
Traceback (most recent call last):
File "/Users/damien/Documents/Developpement/Python/whisper-cpp-python/test.py", line 3, in <module>
output = whisper.transcribe(open('./vendor/whisper.cpp/samples/jfk.wav'))
File "/Users/damien/Documents/Developpement/Python/whisper-cpp-python/whisper_cpp_python/whisper.py", line 21, in transcribe
data, sr = librosa.load(file, sr=Whisper.WHISPER_SR)
File "/Users/damien/miniconda3/envs/tensorflow/lib/python3.9/site-packages/librosa/core/audio.py", line 186, in load
raise exc
File "/Users/damien/miniconda3/envs/tensorflow/lib/python3.9/site-packages/librosa/core/audio.py", line 176, in load
y, sr_native = __soundfile_load(path, offset, duration, dtype)
File "/Users/damien/miniconda3/envs/tensorflow/lib/python3.9/site-packages/librosa/core/audio.py", line 209, in __soundfile_load
context = sf.SoundFile(path)
File "/Users/damien/miniconda3/envs/tensorflow/lib/python3.9/site-packages/soundfile.py", line 658, in __init__
self._file = self._open(file, mode_int, closefd)
File "/Users/damien/miniconda3/envs/tensorflow/lib/python3.9/site-packages/soundfile.py", line 1216, in _open
raise LibsndfileError(err, prefix="Error opening {0!r}: ".format(self.name))
soundfile.LibsndfileError: Error opening <_io.TextIOWrapper name='./vendor/whisper.cpp/samples/jfk.wav' mode='r' encoding='UTF-8'>: Format not recognised. I don't understand this error, do you have any idea? Thanks for your time! |
@DamienDabernat don't know if you've solved but have you checked if elif sys.platform == "darwin":
lib_ext = ".dylib" without renaming this _lib_paths = [
_base_path / f"lib{lib_base_name}{lib_ext}",
_base_path / f"{lib_base_name}{lib_ext}",
] the "lib" prefix is attached to the base. I know that your modification is not breaking the code, but I thought it worth to mention it. After that I was able to correctly load the model and to perform inference correctly. |
Hey @carloscdias , this fix won't work as the error is thrown on the import line itself. Do you have any other workarounds? |
@devilteo911 Yes ffmpeg is correctly installed but the error I'm going to investigate more this evening. |
I found the problem!
So, adding |
Fix from carloscdias#9 Basically on macOS we were trying to load the wrong file 😊
Hi,
Is there any way to fix this? |
|
Hello, thanks for your work !
I'm not the best in python and I have some trouble to install this module.
I use miniconda3 on a Macbook M1. I can install this module with pip with no problem. But when I try to import the module, there is an error :
FileNotFoundError: Shared library with base name 'whisper' not found
.Here's the stack trace :
Do I missing something obvious ?
The text was updated successfully, but these errors were encountered: