chidiwilliams / buzz

Buzz transcribes and translates audio offline on your personal computer. Powered by OpenAI's Whisper.
https://chidiwilliams.github.io/buzz
MIT License
11.95k stars 899 forks source link

ImportError: Could not load whisper. #857

Closed Uday-P-Patel closed 1 month ago

Uday-P-Patel commented 1 month ago

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

raivisdejus commented 1 month ago

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.)

Uday-P-Patel commented 1 month ago

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?

raivisdejus commented 1 month ago

@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

raivisdejus commented 1 month ago

@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:

Uday-P-Patel commented 1 month ago

@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

raivisdejus commented 1 month ago

@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

Uday-P-Patel commented 1 month ago

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

raivisdejus commented 1 month ago

Sadly I am out of ideas here.

Uday-P-Patel commented 1 month ago

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

raivisdejus commented 1 month ago

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)

Uday-P-Patel commented 1 month ago

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