ImportError: DLL load failed while importing _impl: A dynamic link library (DLL) initialization routine failed. (while importing deepspeech library)

what did I do wrong now please try to understand I am not making fun of anyone I am not able to make any progress in my project. If there was a way I could do it by myself I would have already done that, I have searched google for this problem put a question on stack overflow but there a user guided me here.

here is a link for that

  • not following the required guidelines for sharing your problem
  • linking to a video tutorial not made by us: do you really expect people who want to help you viewing a video to know what you might have did wrong? I don’t have time for that
  • not sharing all the exact steps you took to reproduce your issue ; just stating “I installed using pip” is not enough, because we can’t verify what you did

Now, too bad, but I can’t spend my whole day helping you, so you have basically ran out of time with me, I need to work.

1 Like

Agreed I wouldn’t have helped a person Like that either. I am sorry to waste your and @othiele time.

But still, I am a 11-grade student wanting to complete a project before the next session starts.

so If anyhow you got time then kindly help I am writing all the thing in order I did

  1. I already had Python 3.9 so nothing for that
  2. Then I downloaded deepdpeech via this command pip install deepspeech
  3. Then I created a virtual environment in the current working directory by using the inbuilt feature in pycharm

.

  1. then I downloaded a pre-trained model deepspeech-0.9.3-models.pbmm file from the GitHub
    I also downloaded the deepspeech-0.9.3-models.scorer file from Github.

  2. Then I followed this website to make it work(I was trying to use your docs but they were not understandable by me that is why I read from there and also the video)

  3. according to them here is my code:

import deepspeech
import wave
import numpy as np

modelPath = 'D:\Coding\jarvis\deepspeech-0.9.3-models.pbmm'

model = deepspeech.Model(modelPath)

scorerPath = 'D:\Coding\jarvis\deepspeech-0.9.3-models.scorer'

model.enableExternalScorer(scorerPath)

lm_alpha = 0.75
lm_beta = 1.85
model.setScorerAlphaBeta(lm_alpha, lm_beta)

beam_width = 500
model.setBeamWidth(beam_width)


filename = 'audio/8455-210777-0068.wav'
w = wave.open(filename, 'r')
rate = w.getframerate()
frames = w.getnframes()
buffer = w.readframes(frames)
print(rate)
print(model.sampleRate())
type(buffer)

data16 = np.frombuffer(buffer, dtype=np.int16)

text = model.stt(data16)
print(text)

after that when I run I am getting this error:

Traceback (most recent call last):
  File "D:\Coding\jarvis\main.py", line 1, in <module>
    import deepspeech
  File "C:\Users\saura\AppData\Local\Programs\Python\Python39\lib\site-packages\deepspeech\__init__.py", line 23, in <module>
    from deepspeech.impl import Version as version
  File "C:\Users\saura\AppData\Local\Programs\Python\Python39\lib\site-packages\deepspeech\impl.py", line 13, in <module>
    from . import _impl
ImportError: DLL load failed while importing _impl: A dynamic link library (DLL) initialization routine failed.

I have performed all of the above steps 3-4 times now and in python version 3.8 and 3.9 but the same error always.

like @lissyx I am so fed up with this I just can’t explain so kindly help if anyone knows the answer

If it is just for testing, why don’t you start a Google colab and install via pip. This is done in 2 minutes.

32 bits? 64 bits?

we said no screenshots

we also don’t support conda, please use vanilla venv.

“followed this website”, no link, no steps, I don’t have time

Being a student is not an excuse, it’s not like we have not been patient and repeatedly tried.

Python version 3.8 and 3.9 both are 64bit

I already used that but same thing.

Didn’t gave the link as I gave the code but here it is if you need it.

I can’t deny the fact that after all that you guys are still helping thanks a lot

I have to implement it in an app that is why I am using pycharm

Well, I can only ask you to re-try from scratch without any pycharm, conda or anything, and using only our deepspeech facing CLI.

Basically follow https://deepspeech.readthedocs.io/en/v0.9.3/USING.html#using-the-python-package.

I need you to be 10000% sure about that. 99% of the dll failure on Windows were tracked to python 32 bits, the other 99% to wrong CUDA dependencies.

At some point, if it’s still failing, there’s basically nothing I can do, investigating DLL loading issues is non trivial and likely to be out of your scope of knowledge, unfortunately.

Can you also verify it’s not just missing redistribuable c++ as documented here https://deepspeech.readthedocs.io/en/v0.9.3/USING.html#using-a-pre-trained-model ?

Have a look at this project, which distributes DS and seems to work for people:

1 Like

I tried that aswell but it didnt worked out same error

I am 100000% sure about that. As I reinstalled both of them and both were 64 bit, I also double checked it in cmd.

That is one of the first things I did before I asked on this forum

Maybe I should just drop the Idea of using deepspeech though I will try @othiele shared post. also have you checked the image in the main post.(the linked text saying this)

It might give a hint to you.

I’m sorry, but debugging DLL loading is complicated. If you’re confident you have correctly followed our docs, with deps, on a clean state, there’s not much I can do.

Did you see that screenshot? Or maybe tell me how the older thread was solved.

No, as I said, I don’t read into screenshots.

What are you referring to?

This one

Seriously ? My last message there was asking the reporter to hack, we never knew why it fails, and we never reproed.

@Saurav_Prashar Actually, he even gave you a solution: "ImportError: DLL load failed: The specified module could not be found." when running deepspeech my ask was about debugging WHY our code which should be able to load properly was failing.

Try and move files as he suggested, if it works, you should debug https://github.com/mozilla/DeepSpeech/blob/7b2eeb6734a49c3d9439644e9fe0685cb46ad695/native_client/python/__init__.py#L8-L18

Ill try doing that tomorrow its like 12am here and its been 12 hrs i have been sitting i front of my pc :pleading_face:

Timezones are complicated, nobody should ever expect you to be 100% available outside of it. Often, resting and sleeping fixes bugs, you should not worry.

Same error It didn’t help me, maybe I am just making the project more complicated for my skill level.

By The way, I just think a little bit that you should take a look at the screenshot shared In the main post

stop that, think a bit about others: what if your interlocutor has no mean to read into a screenshots?