buriburisuri/speech-to-text-wavenet

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

mehulGupta7991 opened this issue · 1 comments

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

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