def plot_from_range_dict(range_dict, pdf_path, nr_fft=100, len_fft=1024, nr_mel_bins=100): """ Plot the ranges in the range_dict in mel spectrum scale and save to file Parameters: ----------- range_dict : dictionary Dictionary whose keys are the filenames and values are list of lists of start and end time for the training interval ranges. pdf_path : string Path to a location where a pdf file is created containing the plots for all ranges in range_dict nr_fft : int The number of ffts in each stft calculation len_fft : int The length of each of the nr_fft fourier transforms for each stft nr_mel_bins : int The number of bins in which the mel spectrum is to be divided in Results: -------- None """ X = intvpck.train_interval_mel_features(range_dict, nr_fft=nr_fft, len_fft=len_fft, nr_mel_bins=nr_mel_bins) plot_titles_lst = pckhlp.plot_titles_list_from_dict(range_dict) pckhlp.save_feat_in_pdf(X, (nr_mel_bins, nr_fft), pdf_path, plot_titles_lst) return None
def plot_from_range_dict(range_dict,pdf_path,nr_fft = 100, len_fft = 1024, nr_mel_bins = 100): """ Plot the ranges in the range_dict in mel spectrum scale and save to file Parameters: ----------- range_dict : dictionary Dictionary whose keys are the filenames and values are list of lists of start and end time for the training interval ranges. pdf_path : string Path to a location where a pdf file is created containing the plots for all ranges in range_dict nr_fft : int The number of ffts in each stft calculation len_fft : int The length of each of the nr_fft fourier transforms for each stft nr_mel_bins : int The number of bins in which the mel spectrum is to be divided in Results: -------- None """ X = intvpck.train_interval_mel_features(range_dict, nr_fft = nr_fft, len_fft = len_fft, nr_mel_bins = nr_mel_bins) plot_titles_lst = pckhlp.plot_titles_list_from_dict(range_dict) pckhlp.save_feat_in_pdf(X, (nr_mel_bins,nr_fft), pdf_path,plot_titles_lst) return None
def compute_range_dict(source_file_path, pattern, config_par, fs): """ Compute the range dictionary for a single audio file for a given pattern. Paramters: ---------- source_file_path : string Path to the input wav file with sample frequency fs. pattern : ndarray The timeseries pattern which is used to calculate the correlation with data. In sample frequency fs. config_par : dict Dictionary containing all the required configuration parameter fs : float The sample frequency (frames per second) of the data Returns: -------- range_dict : dictionary Dictionary whose keys are the filenames and values are list of lists of start and end time for the training interval ranges. roll_max_peaks : ndarray Rolling maximum of data normalised by its rolling mean. """ # -- Calculate the average correlation over all freq_range_fft_bins between source and pattern peaks = correlation_picking(source_file_path, pattern, config_par['freq_range_fft_bins'], len_fft=config_par["len_fft"], nr_ffts_per_s=config_par["nr_ffts_per_s"], pattern_len_s=config_par["pattern_len_sec"]) # -- Identify frames of isolated peaks centre_frames, roll_max_peaks = peak_identification( peaks, width_in_s=config_par["peak_mute_width"], width_roll_mean=config_par["width_roll_mean"], roll_max_peaks_threshold=config_par['peaks_threshold'], fs=fs, nr_ffts_per_s=config_par["nr_ffts_per_s"], chunk_len_s=60, len_fft=config_par['len_fft'], is_ret_roll_max_peaks=True) print 'centre_frames', centre_frames # -- Create range dictionary around isolated peaks range_dict = intvpck.training_range_times_from_peaktimes( centre_frames, config_par["range_len_sec"], source_file_path, fs) return range_dict, roll_max_peaks
def compute_range_dict(source_file_path, pattern, config_par ,fs): """ Compute the range dictionary for a single audio file for a given pattern. Paramters: ---------- source_file_path : string Path to the input wav file with sample frequency fs. pattern : ndarray The timeseries pattern which is used to calculate the correlation with data. In sample frequency fs. config_par : dict Dictionary containing all the required configuration parameter fs : float The sample frequency (frames per second) of the data Returns: -------- range_dict : dictionary Dictionary whose keys are the filenames and values are list of lists of start and end time for the training interval ranges. roll_max_peaks : ndarray Rolling maximum of data normalised by its rolling mean. """ # -- Calculate the average correlation over all freq_range_fft_bins between source and pattern peaks = correlation_picking(source_file_path,pattern,config_par['freq_range_fft_bins'], len_fft = config_par["len_fft"], nr_ffts_per_s = config_par["nr_ffts_per_s"], pattern_len_s = config_par["pattern_len_sec"] ) # -- Identify frames of isolated peaks centre_frames,roll_max_peaks = peak_identification(peaks, width_in_s = config_par["peak_mute_width"], width_roll_mean = config_par["width_roll_mean"], roll_max_peaks_threshold = config_par['peaks_threshold'], fs = fs,nr_ffts_per_s = config_par["nr_ffts_per_s"], chunk_len_s = 60,len_fft = config_par['len_fft'], is_ret_roll_max_peaks = True) print 'centre_frames',centre_frames # -- Create range dictionary around isolated peaks range_dict = intvpck.training_range_times_from_peaktimes(centre_frames, config_par["range_len_sec"],source_file_path,fs) return range_dict,roll_max_peaks