def _generate_aldebaran_dataset(files, nfft=1024, expected_fs=48000, window_block=None): assert (files != []) res = [] for num, f in enumerate(files): try: data = {} data['file_path'], data['file_name'] = os.path.split(f) data['full_filename'] = f data['expected_class'] = data['file_name'].split('-')[0] signal, fs = load_sound(f) if fs != expected_fs: print( "warning file %s, wrong fs %s, using it.. please remove the file if you don't want" % (f, fs)) #continue for frame_feature in extract_mfcc_features_one_channel( signal, nfft=nfft, window_block=window_block, fs=fs): data['features'] = frame_feature res.append(data) except Exception as e: print("ERROR on %s" % f) print(traceback.format_exc()) return res
def _generate_humavips_dataset(glob_file_pattern="/mnt/protolab_server/media/sounds/datasets/NAR_dataset/*/*.wav", nfft=1024): files = glob.glob(glob_file_pattern) assert(files!=[]) res = [] for num, f in enumerate(files): try: data = {} data['file_path'], data['file_name'] = os.path.split(f) data['expected_class'] = os.path.split(data['file_path'])[-1] signal, fs = load_sound(f) data['features'] = extract_mfcc_features_one_channel(signal, nfft=nfft) res.append(data) except Exception as e: print("ERROR on %s" % f) print(traceback.format_exc()) return res
def _generate_humavips_dataset( glob_file_pattern="/mnt/protolab_server/media/sounds/datasets/NAR_dataset/*/*.wav", nfft=1024): files = glob.glob(glob_file_pattern) assert (files != []) res = [] for num, f in enumerate(files): try: data = {} data['file_path'], data['file_name'] = os.path.split(f) data['expected_class'] = os.path.split(data['file_path'])[-1] signal, fs = load_sound(f) data['features'] = extract_mfcc_features_one_channel(signal, nfft=nfft) res.append(data) except Exception as e: print("ERROR on %s" % f) print(traceback.format_exc()) return res
def _generate_aldebaran_dataset(files, nfft=1024, expected_fs=48000, window_block=None): assert(files!=[]) res = [] for num, f in enumerate(files): try: data = {} data['file_path'], data['file_name'] = os.path.split(f) data['full_filename'] = f data['expected_class'] = data['file_name'].split('-')[0] signal, fs = load_sound(f) if fs!=expected_fs: print("warning file %s, wrong fs %s, using it.. please remove the file if you don't want" % (f, fs)) #continue for frame_feature in extract_mfcc_features_one_channel(signal, nfft=nfft, window_block=window_block, fs=fs): data['features'] = frame_feature res.append(data) except Exception as e: print("ERROR on %s" % f) print(traceback.format_exc()) return res
def _generate_8k_dataset_dict(glob_file_pattern='/mnt/protolab_server_8k/fold*/*.wav', nfft=1024, downsampling_freq=None): """ :param glob_file_pattern: :param nfft: :param downsampling_freq: if set it's used for downsampling :return: """ files = glob.glob(glob_file_pattern) assert(files!=[]) res = [] for num, f in enumerate(files): try: data = {} data['file_path'], data['file_name'] = os.path.split(f) signal, fs = load_sound(f) # using channel_1 only if downsampling_freq: signal, fs = downsample_signal(signal, origin_fs=fs, final_fs=downsampling_freq) data['fs'] = fs try: features = extract_mfcc_features_one_channel(signal, nfft=nfft) data['features'] = features except Exception as e: import IPython IPython.embed() res.append(data) except Exception as e: print("ERROR on %s" % f) print(traceback.format_exc()) return res