def build_predictions(audio_dir):
    y_true = []
    y_pred = []
    fn_prob = {}
    if (len(os.listdir(audio_dir)) == 0):
        print('No files found for classification')
        return (False, False, False)
    print('Extracting feature from audio files')
    for file in tqdm(os.listdir(audio_dir)):
        try:
            (rate, signal) = wavfile.read(os.path.join(audio_dir, file))
            label = filename_to_class[file]
            c = classes.index(label)
            y_prob = []
            print('Classifying audio files')
            for i in tqdm(range(0, (signal.shape[0] - config.step), config.step)):
                sample = signal[i:(i + config.step)]
                x = mfcc(sample, rate, numcep=config.nfeat, nfilt=config.nfilt, nfft=config.nfft)
                x = ((x - config._min) / (config._max - config._min))
                if (config.mode == 'conv'):
                    x = x.reshape(1, x.shape[0], x.shape[1], 1)
                elif (config.mode == 'time'):
                    x = np.expand_dims(x, axis=0)
                y_hat = model.predict(x)
                y_prob.append(y_hat)
                y_pred.append(np.argmax(y_hat))
                y_true.append(c)
            fn_prob[file] = np.mean(y_prob, axis=0).flatten()
        except:
            print('Something went wrong some files', sys.exc_info()[0])
    return (y_true, y_pred, fn_prob)
def build_predictions(audio_dir):
    y_true = []
    y_pred = []
    fn_prob = {}
    if (len(os.listdir(audio_dir)) == 0):
        print('No files found for classification')
        return (False, False, False)
    print('Extracting feature from audio files')
    for file in tqdm(os.listdir(audio_dir)):
        try:
            (rate, signal) = wavfile.read(os.path.join(audio_dir, file))
            label = filename_to_class[file]
            c = classes.index(label)
            y_prob = []
            print('Classifying audio files')
            for i in tqdm(range(0, (signal.shape[0] - config.step), config.step)):
                sample = signal[i:(i + config.step)]
                x = mfcc(sample, rate, numcep=config.nfeat, nfilt=config.nfilt, nfft=config.nfft)
                x = ((x - config._min) / (config._max - config._min))
                if (config.mode == 'conv'):
                    x = x.reshape(1, x.shape[0], x.shape[1], 1)
                elif (config.mode == 'time'):
                    x = np.expand_dims(x, axis=0)
                y_hat = model.predict(x)
                y_prob.append(y_hat)
                y_pred.append(np.argmax(y_hat))
                y_true.append(c)
            fn_prob[file] = np.mean(y_prob, axis=0).flatten()
        except:
            print('Something went wrong some files', sys.exc_info()[0])
    return (y_true, y_pred, fn_prob)