Comments (28)
Damn, was looking forward to benchmarking cuda whisper.cpp. Anyways, fun little adventure tonight. Have a good one man. I'll follow new releases for when you include the .dll and/or support GPU. How hard can it be, to support cuda, vulkan, openblas, etc. ;-)
from pywhispercpp.
Seems like Python cannot see the DLL module for some reason, even though the wheels were built successfully for Windows.
I would suggest to try to build the package from source or use WSL.
from pywhispercpp.
I confirm this problem exists. Building from source results in the same error.
from pywhispercpp.
@NBNGaming,
if building from source leads to the same error, then I think something's missing from your system, because the Winodws wheels have been successfully built using GitHub actions without any issue.
Please make sure that you have the GCC toolchain and you can compile whisper.cpp
first without any problems.
from pywhispercpp.
I'm getting the same exact error message regarding the .dll file...I searched the "lib" directory after pip installing and there are no .dll files within that directory. Any idea why?
I'm not an expert so forgive me, but am I supposed to build whisper.cpp first and then install pywhispercpp? ggerganov's repo? I'm unfamiliar with building but can learn, but need to know if I have to install whisper.cpp first please. Thanks!
BTW, I don't know what GCC toolchain means...
Windows 10
CUDA 12.5
Intel CPU
from pywhispercpp.
@BBC-Esq, I am not quite sure why this is happening on Windows!
Usually, you don't need to build whisper.cpp
if you pip installed the package and basically it should work out of the box. However if the pre-built wheel for your system is not working then you might need to build the project from source.
But, before going through this path, here are some suggestions:
- If you are using Python
3.12
, try to downgrade to3.10
or3.11
. This might solve the issue. - Otherwise, use WSL instead if you are unfamiliar with building, this will work without issues I assume.
from pywhispercpp.
I'm using Python 3.11. Not familiar with WSL...any other ideas? Have you actually tested it on Windows?
from pywhispercpp.
Apart from the Github action which ran successfully, I didn't make any tests on Windows unfortunately, I only tested the project on Linux.
I just double checked now the pre-built Windows wheel for Python 3.11
pywhispercpp-1.2.0-cp311-cp311-win_amd64.whl and I can see that the dll .pyd
file is there.
Could you please double check on your end ?
from pywhispercpp.
Actually, it wasn't that hard to test and it gave me this error:
Traceback (most recent call last):
File "D:\Scripts\benchmark_whisper\bench_whisper_cpp.py", line 1, in <module>
from pywhispercpp.model import Model
File "D:\Scripts\benchmark_whisper\Lib\site-packages\pywhispercpp\model.py", line 13, in <module>
import _pywhispercpp as pw
ImportError: DLL load failed while importing _pywhispercpp: The specified module could not be found.
I did pip install and then the link to the wheel you gave me.
Here is the directory structure that another script of mine culled...Everything from the "pywhispercpp" directory downwards:
pywhispercpp/
constants.py
model.py
utils.py
_logger.py
__init__.py
examples/
assistant.py
livestream.py
main.py
recording.py
__init__.py
__pycache__/
assistant.cpython-311.pyc
livestream.cpython-311.pyc
main.cpython-311.pyc
recording.cpython-311.pyc
__init__.cpython-311.pyc
__pycache__/
constants.cpython-311.pyc
model.cpython-311.pyc
utils.cpython-311.pyc
_logger.cpython-311.pyc
__init__.cpython-311.pyc
I noticed that the .pyd file is one level up within the "site-packages" folder though.
from pywhispercpp.
Correction in case you didn't see my edit to the above message...The .pyd file is a directory higher in "site-packages".
from pywhispercpp.
@BBC-Esq, so it's there at least. Not sure why Windows cannot find it!!
Can you in that case put the pyd
file inside the pywhispercpp directory ?
Or Maybe if didn't work try to put it also in your current working directory D:\Scripts\benchmark_whisper\
?
from pywhispercpp.
Sure, I'll put it in both at the same time.
from pywhispercpp.
Same exact error as before. Might it be that you're importing "_pywhispercpp" with an underscore at the beginning instead of simply "pywhispercpp"?
from pywhispercpp.
The script I'm using is very simple. I even modified it to add appending the system path but am still getting the same error...
import sys
import os
from pywhispercpp.model import Model
# Add the directory containing the .pyd file to the sys.path
sys.path.append(os.path.dirname(os.path.abspath(r"D:\Scripts\benchmark_whisper\Lib\site-packages\_pywhispercpp.cp311-win_amd64.pyd")))
model = Model('base.en', n_threads=6)
segments = model.transcribe(r"D:\Scripts\benchmark_whisper\test_audio_flac_converted.wav", speed_up=True)
for segment in segments:
print(segment.text)
from pywhispercpp.
No, the _pywhispercpp
is the extension module :)
Can you try with os.add_dll_directory instead of sys.path.append
from pywhispercpp.
Hmm...same as before...
from pywhispercpp.
Hmm...same as before...
You should use os.add_dll...
before the import!
from pywhispercpp.
Same error as before and here's the modified script:
import os
dll_path = r"D:\Scripts\benchmark_whisper\_pywhispercpp.cp311-win_amd64.pyd"
dll_directory = os.path.dirname(dll_path)
os.add_dll_directory(dll_directory)
from pywhispercpp.model import Model
model = Model('base.en', n_threads=6)
segments = model.transcribe(r"D:\Scripts\benchmark_whisper\test_audio_flac_converted.wav", speed_up=True)
for segment in segments:
print(segment.text)
I also tried this script:
import os
import ctypes
dll_path = r"D:\Scripts\benchmark_whisper\_pywhispercpp.cp311-win_amd64.pyd"
dll_directory = os.path.dirname(dll_path)
with os.add_dll_directory(dll_directory):
ctypes.CDLL(dll_path)
from pywhispercpp.model import Model
model = Model('base.en', n_threads=6)
segments = model.transcribe(r"D:\Scripts\benchmark_whisper\test_audio_flac_converted.wav", speed_up=True)
for segment in segments:
print(segment.text)
It gave me a slightly different error:
Traceback (most recent call last):
File "D:\Scripts\benchmark_whisper\bench_whisper_cpp.py", line 8, in <module>
ctypes.CDLL(dll_path)
File "C:\Users\Airflow\AppData\Local\Programs\Python\Python311\Lib\ctypes\__init__.py", line 376, in __init__
self._handle = _dlopen(self._name, mode)
^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: Could not find module 'D:\Scripts\benchmark_whisper\_pywhispercpp.cp311-win_amd64.pyd' (or one of its dependencies). Try using the full path with constructor syntax.
NOTE: It says "or one of its dependencies"
from pywhispercpp.
Windows is weird to be honest!
if it complains about the dependencies then maybe you need Windows c++ redistributables or something! A lot of things can go wrong! Not quite sure what's the real issue.
That's why I suggested to use WSL!
In that case try to build whisper.cpp
first and see if it works, you can find the instructions on their reop.
from pywhispercpp.
I asked jeeves and he told me to try "dependency walker" from Microsoft but it didn't work...https://www.dependencywalker.com/
Then I tried https://github.com/lucasg/Dependencies/releases/tag/v1.11.1
The "file" "open" dialog only lets you select .dll files so you'll have to drag and drop the .pyd file...Anyways, this is what it gave me:
It seems that "whisper.dll" is missing? So basically, I need to install openai's whisper?
from pywhispercpp.
Great idea @BBC-Esq,
Here is the whisper.dll
file from ggerganov/whisper.cpp
repo.
Maybe include it in the same directroy as well, hopefully this will solve the issue
from pywhispercpp.
Fucking A...it worked. I put it in the "site-packages" folder, the "benchmark_whisper" folder, and the "pywhispercpp" folder and it worked...now it's just a matter of narrowing it down to which folder hierarchy it should be in.
from pywhispercpp.
...correction, it didn't actually work. It resolved that error, but now I'm getting "failed to compute log mel spectrogram:"
[2024-05-29 22:58:13,706] {utils.py:38} INFO - No download directory was provided, models will be downloaded to C:\Users\Airflow\AppData\Local\pywhispercpp\pywhispercpp\models
[2024-05-29 22:58:13,707] {utils.py:46} INFO - Model base.en already exists in C:\Users\Airflow\AppData\Local\pywhispercpp\pywhispercpp\models
[2024-05-29 22:58:13,707] {model.py:221} INFO - Initializing the model ...
whisper_init_from_file_with_params_no_state: loading model from 'C:\Users\Airflow\AppData\Local\pywhispercpp\pywhispercpp\models\ggml-base.en.bin'
whisper_model_load: loading model
whisper_model_load: n_vocab = 51864
whisper_model_load: n_audio_ctx = 1500
whisper_model_load: n_audio_state = 512
whisper_model_load: n_audio_head = 8
whisper_model_load: n_audio_layer = 6
whisper_model_load: n_text_ctx = 448
whisper_model_load: n_text_state = 512
whisper_model_load: n_text_head = 8
whisper_model_load: n_text_layer = 6
whisper_model_load: n_mels = 80
whisper_model_load: ftype = 1
whisper_model_load: qntvr = 0
whisper_model_load: type = 2 (base)
whisper_model_load: adding 1607 extra tokens
whisper_model_load: n_langs = 99
whisper_model_load: CPU buffer size = 147.46 MB
whisper_model_load: model size = 147.37 MB
whisper_init_state: kv self size = 16.52 MB
whisper_init_state: kv cross size = 18.43 MB
whisper_init_state: compute buffer (conv) = 14.86 MB
whisper_init_state: compute buffer (encode) = 85.99 MB
whisper_init_state: compute buffer (cross) = 4.78 MB
whisper_init_state: compute buffer (decode) = 96.48 MB
[2024-05-29 22:58:14,083] {model.py:130} INFO - Transcribing ...
whisper_full_with_state: failed to compute log mel spectrogram
[2024-05-29 22:58:14,083] {model.py:133} INFO - Inference time: 0.000 s
from pywhispercpp.
Finally! so that's what was missing! I should find a way to include it with the wheel!
For the failed to compute log mel spectrogram
error, just remove speed_up
True or set it to False!
from pywhispercpp.
I/we fixed it! Mind explaining to me what whisper.dll
is and why we need it? Also, I have cuda installed. How can I use gpu acceleration in my script?
import os
import ctypes
dll_directory = r"D:\Scripts\benchmark_whisper\Lib\site-packages"
ctypes.windll.kernel32.SetDllDirectoryW(dll_directory)
ctypes.CDLL(os.path.join(dll_directory, '_pywhispercpp.cp311-win_amd64.pyd'))
from pywhispercpp.model import Model
model = Model(r"D:\Scripts\benchmark_whisper\Models\ggml-large-v2-q5_0.bin", n_threads=6)
segments = model.transcribe(r"D:\Scripts\benchmark_whisper\test_audio_flac_converted.wav", speed_up=False)
for segment in segments:
print(segment.text)
from pywhispercpp.
...do tell me you've implemented the gpu acceleration like cuda, etc. in your repo? I don't see anything in the documentation about a cuda let alone any other gpu acceleration parameters... ;-)
from pywhispercpp.
The whisper.dll
is very simply the file containing the executable code of whisper.cpp
.
Unfortunately GPU is not supported at the moment, I didn't find time to add it!
from pywhispercpp.
It shouldn't be so hard I assume, but it'll need time, this is the problem :)
But feel free to take a look at the code as well, PRs are always welcome!
from pywhispercpp.
Related Issues (20)
- Unknown language error HOT 4
- How to make transcription and speaker diarization using pywhispercpp HOT 1
- How to use coreML models in Mac M2? HOT 3
- "Cannot find source file: ggml.h" when trying to install on Ubuntu 22.04 on aarch64 HOT 3
- Integrating pywhispercpp as the first extension to lollms-webui HOT 2
- Nothing happens HOT 13
- pywhispercpp/whisper.cpp/ggml-opencl.c:4:10: fatal error: 'clblast_c.h' file not found #include <clblast_c.h> HOT 9
- ERROR - Invalid model name `./model.bin` HOT 1
- ERROR - unable to initialize from path HOT 5
- Unable to install on raspberry pi 4 HOT 5
- How to add space between subtitles? HOT 1
- word-level timestamps? HOT 5
- About GPU question HOT 1
- Using the agent for interacting with ollama models HOT 29
- Tool is super slow / runs forever HOT 10
- Unable to load `quantized` models HOT 3
- "ggml-metal.metal" file couldn't be found when loading the large-v3 model for CoreML HOT 7
- failed to compute log mel spectrogram HOT 3
- Installation from source leads to non-functional installation HOT 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pywhispercpp.