models icon indicating copy to clipboard operation
models copied to clipboard

vocabulary should contain blank to make the decoder API easy to use.

Open chenjiasheng opened this issue 9 years ago • 2 comments

https://github.com/PaddlePaddle/models/blob/8b5c739a847b03ae8e7daa10f5311ef8cd12290b/deep_speech_2/model_utils/decoder.py#L87

If vocabulary dosen't contain blank, we have:

vocabulary=['a', 'b', ..., 'z', ' ', '.']
len(vocabulary) = 28
len(prob_list) = 29

Then at line 135,

new_char = vocabulary[c]

here c ranges from 0 to len(prob_list), but vocabulary[28] causes index out of range.

To use this decoder, one have to make the vocabulary a dict indexed from 1 instead of a list indexed from 0, in spite of that the doc suggests vocabulary to be a list.

    :param vocabulary: Vocabulary list.
    :type vocabulary: list

This is really confusing.

@xinghai-sun @kuke

chenjiasheng avatar Sep 15 '17 03:09 chenjiasheng

@chenjiasheng Thanks for your attention!

This wouldn't happen because we in fact have enforced blank_id equal to len(vocabulary). And blank_id shouldn't be passed as an argument to the decoder, we have fixed that in the C++ decoders and will fix the python version very soon.

kuke avatar Sep 15 '17 15:09 kuke

@kuke OK, thanks for the reply.

chenjiasheng avatar Sep 18 '17 02:09 chenjiasheng