Native client metadata

Greetings! I am currently trying to see the metadata that an inference returns. I have looked into the code under this function it prints out the help line, but when I compile it over on python it doesn’t print out that exact help display. So I take it that displaying metadata only works on the C side? If so how would one compile the C to see the metadata?

It’s in the python client too, see here. Are you using your newer compiled client or some older, e.g. 0.4.1, client?

The exposed structs are documented in the header: https://github.com/mozilla/DeepSpeech/blob/35cbc16697461c2d5963e508e877b83dd4be4bda/native_client/deepspeech.h#L19-L31

I freshly compiled the docker, and ran an inference with this line (currently the model is like 93% wer just testing).

root@2d0cdcceaca4:/DeepSpeech# deepspeech --model finished_models/output_graph.pb --alphabet data/alphabet.txt --audio audio.wav --extended

I am influencing on CPU currently and it just outputs what it normally does without –extended.

If you read the doc, you will learn it is expected: we produce the same output, but we do so using the Metadata API.

Alright, so I would have to customize the code to allow the metadata to be printed out as well? Since I am trying to print out the probability and or the timing of the characters.

You need to use the --json flag.

deepspeech --model ./finished/output_graph.pb --alphabet ./data/alphabet.txt --audio /audio/4507-16021-0012.wav --lm ./data/lm/lm.binary --trie ./data/trie --extended --json
usage: deepspeech [-h] --model MODEL --alphabet ALPHABET [–lm [LM]]
[–trie [TRIE]] --audio AUDIO [–version] [–extended]
deepspeech: error: unrecognized arguments: --json

I am using the native_client deepspeech compiled using a docker file. Running deepspeech -h shows

usage: deepspeech [-h] --model MODEL --alphabet ALPHABET [–lm [LM]]
[–trie [TRIE]] --audio AUDIO [–version] [–extended]

Running DeepSpeech inference.

optional arguments:
-h, --help show this help message and exit
–model MODEL Path to the model (protocol buffer binary file)
–alphabet ALPHABET Path to the configuration file specifying the alphabet
used by the network
–lm [LM] Path to the language model binary file
–trie [TRIE] Path to the language model trie file created with
native_client/generate_trie
–audio AUDIO Path to the audio file to run (WAV format)
–version Print version and exits
–extended Output string from extended metadata

It doesn’t specify anything about --json flag that is referenced in args.h.
Just wondering what needs to be done in order to use the --json flag and retrieve probability / the timing of characters.

Can you document exactly what you did ? Why rebuilding yourself instead of using the prebuilt binaries ?

Also, you don’t need --extended and --json. Just use --json by itself.

The only thing that I have specifically done is build deepspeech using the Dockerfile form the main branch. Train on a small amount of data and try to extract probability using the native_client.

Just using --json without --extended results in the same error message

I have the same problem, also using the dockerfile. I tried to use the --json flag only and got an error: unrecognized arguments: --json
even though:
deepspeech --version is:
TensorFlow: v1.13.1-10-g3e0cc5374d
DeepSpeech: v0.5.0-0-g3db7a99

From reading other things on the forum, and solved my issue you need to run the C client. When you use the command deepspeech it will run it via python. Try following these steps on their readme page which should work. Keep in mind you NEED to do ./deepspeech and not just deepspeech.

1 Like

but why is it not possible to run it via python?

Unsure myself, but I just read it was only available with the C client. If you do a --help it wont display any of it, so I am sure if you make a post about how to get it to work with python one of the collaborators will be able to help you with that.

The --json flag is exposed/implemented in the native client binary only (client.cc). In order to have it available in the Python package you’d have to add that to client.py.

Can you please guide or tell a overview of how to add it in client.py

We already have extensive documentation of the API, what do you need more ?