Problem : Error with Model() function

I am having an issue with implementing the pre-trained model using jupyter (I am using this because I am more familiar with it’s interface). Currently on Tensorflow 2.0, Windows 7.

The error is as listed:

TypeError Traceback (most recent call last)
in
25
26 # Load the acoustic model
—> 27 ds = Model(MODEL_GRAPH, N_FEATURES, N_CONTEXT, LM_ALPHABET, BEAM_WIDTH)
28 print(‘Loaded model’)
29

~\Documents\Anaconda\lib\site-packages\deepspeech_init_.py in init(self, *args, **kwargs)
41 self._impl = None
42
—> 43 status, impl = deepspeech.impl.CreateModel(*args, **kwargs)
44 if status != 0:
45 raise RuntimeError(“CreateModel failed with error code {}”.format(status))

TypeError: CreateModel() takes at most 3 arguments (5 given)

The goal of this is to make a workable inference application with a GUI.

I am still new to all of this so if there is a better way of implementing deepspeech on raspberry pi please free feel to tell me.

Just to rephrase, I wanted to have a model in a file format that i can interact with using Python(in another program). Preferably, in h5 file format.

First, please stick to documented versions. Second, for pure inference, you don’t need TensorFlow.

What is not clear in this error ? You are giving too much parameters.

Ok, I will try that first

Because every post I see about implementing deepspeech uses 5 arg.

def init(self, *args, **kwargs):
# make sure the attribute is there if CreateModel fails
self._impl = None

    status, impl = deepspeech.impl.CreateModel(*args, **kwargs)
    if status != 0:
        raise RuntimeError("CreateModel failed with error code {}".format(status))
    self._impl = impl

This is the code I saw on github. Would you be so kind in telling me what is *args & **kwargs? Because I do not know what param it need for it to work.

Where ?

We have examples in native_client/python/client.py as well as under examples/ and API doc in https://deepspeech.readthedocs.io/en/latest/Python-API.html which is linked from the README.

Please, tell me what is unclear in all those.

Omg thank you so much for this. I did not even saw this link anywhere on the Github page. (Must be my lack of research) Anyway, I will read through this and hopefully this link contains the answers I needed. Thank you so much for your help.

From here.
https://github.com/mozilla/DeepSpeech/blob/master/native_client/python/init.py

1 Like

I don’t understand what to do for removing this error : TypeError: CreateModel() takes at most 2 arguments (5 given)

Thank u in advance :slightly_smiling_face:

Read the documentation and pass the correct amount of parameters?

https://deepspeech.readthedocs.io/en/latest/Python-API.html#native_client.python.Model

Command : python recognize.py models/output_graph.pb ae_recorded.wav models/alphabet.txt models/lm.binary models/trie

I have read the documentation and parameter are all correct according to documentation

Obviously, not.

This is your own code ? Do you expect me to help you without even knowing the code ?

You reply to someone else’s old thread, without any context at all. There is nothing we can do.

no this is not my code
recognize.py code :

i am getting error:
Loading model from file models/output_graph.pb
Traceback (most recent call last):
File “recognize.py”, line 96, in
main()
File “recognize.py”, line 63, in main
ds = Model(args.model, N_FEATURES, N_CONTEXT, args.alphabet, BEAM_WIDTH)
File “/home/robust_audio_ae/env/lib/python3.6/site-packages/deepspeech/init.py”, line 40, in init
status, impl = deepspeech.impl.CreateModel(*args, **kwargs)
TypeError: CreateModel() takes at most 2 arguments (5 given)

It is not our code either, so that still holds.

Ok:

    ds = Model(args.model, N_FEATURES, N_CONTEXT, args.alphabet, BEAM_WIDTH)

Have you read the documentation ? Obviously not.

This code is old. Either use the matching older version of DeepSpeech, or update its use and remove the un-needed parameters. The link I gave you already contains the proper information.

Okk
I will go through the link
Thank u