chidiwilliams/buzz

ImportError: Could not load whisper.

Closed this issue · 11 comments

even if i have followed all the instructions and used poetry to start the app on windows I'm getting this error :

[2024-07-26 10:58:51,813] model_loader.:33 ERROR ->
Traceback (most recent call last):
File "C:\Users\LaptopWala\Desktop\VOXS\VOXS\buzz-main\buzz\model_loader.py", line 29, in
import buzz.whisper_cpp as whisper_cpp # noqa: F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\LaptopWala\Desktop\VOXS\VOXS\buzz-main\buzz\whisper_cpp.py", line 864, in
_libs["whisper"] = load_library("whisper")
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\LaptopWala\Desktop\VOXS\VOXS\buzz-main\buzz\whisper_cpp.py", line 552, in call
raise ImportError("Could not load %s." % libname)
ImportError: Could not load whisper.

and therefor im not able to use whisper.cpp models

You need to make sure whisper.dll and most likely SDL2.dll are in buzz folder. You can run cp .\dll_backup\*.dll .\buzz\ to copy them from the backup. More info on running Buzz locally https://github.com/chidiwilliams/buzz/blob/main/CONTRIBUTING.md#windows

If it still fails to load the DLL that means your computer architecture is not compatible with by the *.dll file. Download appropriate DLL manually from here https://github.com/ggerganov/whisper.cpp/actions/runs/9251036100 (you will need to log into the github to see the artifacts section.)

thanks for the solution, i resolved the library loading issue and now able to select whisper.cpp model type but it is not working, getting this error :

Traceback (most recent call last):
File "C:\Users\LaptopWala\Desktop\VOXS\VOXS\buzz-main\buzz\transcriber\recording_transcriber.py", line 363, in start
model = WhisperCpp(model_path)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\LaptopWala\Desktop\VOXS\VOXS\buzz-main\buzz\transcriber\whisper_cpp.py", line 17, in init
self.ctx = whisper_cpp.whisper_init_from_file(model.encode())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'buzz.whisper_cpp' has no attribute 'whisper_init_from_file'

I followed entire process to run code loclly in windows again to set up new project, is this method supposed to be present in whisper_cpp.py?

@Uday-P-Patel Please try the latest development version from https://github.com/chidiwilliams/buzz/actions/runs/10167390711 (you need to log into the github to see the artifacts section)

If it still fails please tell me what version of Windows are you using and if it is 32bit or 64bit version

@Uday-P-Patel the error AttributeError: module 'buzz.whisper_cpp' has no attribute 'whisper_init_from_file' most likely indicates that the whisper.dll you have is wrong, it does not have the whisper_init_from_file in the right place or it is somehow not found or loaded correctly.

A way to solve this may be to:

  • Return back to the original whisper.dll or a whisper.dll from https://github.com/chidiwilliams/buzz/tree/main/dll_backup
  • This whisper.dll that is aligned with the header files in the whisper.cpp source and whisper_cpp.py. If it does not load you may be missing some of it's dependencies.
  • Load the whisper.dll in https://github.com/lucasg/Dependencies and see if you are missing some further *.dll files
  • Install the missing dependencies or if they are installed their location may be missing from windows PATH

@raivisdejus i tried to roll back to original dll files but the attribute error still persists, also checked for the missing dependencies using this (https://github.com/lucasg/Dependencies) tool and its all there and no dependency is missing please suggest a different solution if there is

@Uday-P-Patel What windows do you have? 32bit or 64bit? what version?

The python bindings in whisper_cpp.py may be broken. To fix that you can run poetry build

I'm on 64bit version and I have done the entire process again including building the project using poetry build still no luck...

Sadly I am out of ideas here.

ok, can you just check one last thing by running the latest version locally that the whisper_cpp.py file that is being generated at runtime has the method "whisper_init_from_file" and check the whisper_cpp.py that is present in transcriber folder in buzz is calling that like:
self.ctx = whisper_cpp.whisper_init_from_file(model.encode())

and if you are able to use whisper.cpp models for transcription correctly, because the file from transcriber folder is calling whisper_init_from_file from whisper_cpp.py that is generated, so if you are able to run it successfully it will have that method and if it have can you share the function def or the file here please

This is my whisper_cpp.py. It's from Ubuntu Linux. whisper_cpp.zip In my tests on Linux or on the virtual machine windows I have everything works.

For windows you may be able to get this file from https://github.com/chidiwilliams/buzz/actions/runs/10237710655/attempts/1 the Buzz-Windows or cibw-wheels-windows-latest (extract the wheel that matches your python version)

see, just what i suspected my python_cpp.py was not built correctly, there was nothing after line 868 i copy pasted the code from yours and it runs perfectly I'm able to use cpp models now, I just need to figure out what is the issue in building but for now I'm good, thanks for the help, just keep the issue open for sometimes ill try from my side and if i find anything ill post here.

thank you once again