buriburisuri / speech-to-text-wavenet

Speech-to-Text-WaveNet : End-to-end sentence level English speech recognition based on DeepMind's WaveNet and tensorflow
Apache License 2.0
3.95k stars 794 forks source link

attribute error byte object have no attribute read in train.py #115

Open mehulGupta7991 opened 5 years ago

ThiagoFPMR commented 3 years ago

You didn't give a detailed description so I can't be sure if we were facing the same exact error. But at some point when the code ran in my machine, it turned the strings containing the paths to the MFCC files into b strings, which is what prompted the attribute error.

I fixed the issue by decoding those strings back into UTF-8 after loading them in the _load_mfcc() function of the data.py file.

@tf.sg_producer_func
def _load_mfcc(src_list):

    # label, wave_file
    label, mfcc_file = src_list
    mfcc_file = mfcc_file.decode(encoding='UTF-8')

    # decode string to integer
    label = np.fromstring(label, np.int)

    # load mfcc
    mfcc = np.load(mfcc_file, allow_pickle=False)

    # speed perturbation augmenting
    mfcc = _augment_speech(mfcc)

    return label, mfcc