diff --git a/README.md b/README.md index 860be2d87a20516889eb8c5bf0aeb38090e6089e..89ec0309aef0379be0ef54d425ca83fc031274b8 100644 --- a/README.md +++ b/README.md @@ -8,17 +8,26 @@ the GSPR loss function with a second-order polynomial. Prerequisite ------------ -This program uses the following libraries (other versions might work): +This program uses the following libraries (tested with the following version): +* cython 0.29 +* numpy 1.21 +* scipy 1.7.1 +* soundfile 0.9 +* scikit-learn 1.0 (needed if you use the hyper resolution mode) +* pandas 1.3 (needed only for saving in a non CSV format) +* tqdm 4.62 (optional if you want a progress bar) Usage ----- - +``` usage: gsrp_tdoa_hyperres.py [-h] [-c CHANNELS] [-i INVERSE] [-f FRAME_SIZE] - [-s HOP_SIZE] [-m MAX_TDOA] [-l LOW] [-u UP] - [-d DECIMATE] [-t] [-e] [--start SECONDS] - [--end SECONDS] + [-s STRIDE | -p STRIDE] [-m MAX_TDOA] + [-S SECONDS] [-E SECONDS] [-l LOW] [-u UP] + [-d DECIMATE] [-t] [-e] [-n] [-w] + [-M {prepare,on-the-fly,auto,smart}] [-q QUOTA] + [-v] infile outfile - +``` Arguments ----- @@ -29,10 +38,9 @@ positional arguments: infile The sound file to process. outfile The text or npy file to write results to. Each row gives the position (in samples), cross-correlation - product, the independent TDOAs (in samples), and TDOAs - derived from the independent ones. For plots, the - panes give the cross-correlation product, independent - TDOAS and derived TDOAs from top to bottom. + product in decibel (normalized and unormalized), the + independent TDOAs (in samples), and TDOAs derived from + the independent ones. optional arguments: -h, --help show this help message and exit @@ -51,11 +59,13 @@ Channels: Size settings: -f FRAME_SIZE, --frame-size FRAME_SIZE The size of the cross-correlation frames in seconds - (default: 0.2) + (default: 0.02) -s STRIDE, --stride STRIDE The step between the beginnings of sequential frames - in seconds (default: 0.01), or the postion in second - if csv file path is given. + in seconds (default: 0.01) + -p STRIDE, --pos STRIDE + The position in second from csv file path. Not allowed + if stride is set -m MAX_TDOA, --max-tdoa MAX_TDOA The maximum TDOA in seconds (default: 0.0011). -S SECONDS, --start SECONDS @@ -76,18 +86,27 @@ Other: -e, --erase Erase existing outfile. If outfile exist and --erase is not provide, the script will exit. -n, --no-hyperres Disable the hyper resolution evalutation of the TDOA - -M {smart,auto,on-the-fly,prepare}, --mode {smart,auto,on-the-fly,prepare} - How to explore the TDOA space (default: prepare). - 'prepare' precomputes all the possible TDOA + -w, --wide Use only one level to concatenate the normal and + hyperres results. Behaviour depends on the output file + type. + -M {prepare,on-the-fly,auto,smart}, --mode {prepare,on-the-fly,auto,smart} + How to explore the TDOA space (default: smart). + prepare precomputes all the possible TDOA pairs and then evaluate them. All the results are save in memory. - 'on-the-fly' compute the TDOA pairs at the same + on-the-fly compute the TDOA pairs at the same time as it compute the loss function. Only the maximum - is saved. Can be slower than 'prepare'. - 'smart' gradually increase the search space dimension, ' - reducing the number of tdoa to evaluate. - 'auto' automatically try to pick the right + is saved. Can be slower than prepare. + smart gradually increase the search space + dimension, reducing the number of tdoa to evaluate. + auto automatically try to pick the right method. - -Process finished with exit code 0 + -q QUOTA, --quota QUOTA + Memory limit in bytes for the + {BColors.BOLD}smart{BColors.ENDC} method. If hit, halt + the computation of the current frame and skip to the + next one. Note that it does not account for other + memory usage, such as the sound data. Can be a unit + such as GB, GiO, Ko, ... + -v, --verbose Activate verbose for smart mode ``` diff --git a/gsrp_tdoa_hyperres.py b/gsrp_tdoa_hyperres.py index 3622fd0bc9c0bdd08f26baa5cbfb2daf755fc346..345873c47e8261360e9abf35e6a02db82e6305c6 100755 --- a/gsrp_tdoa_hyperres.py +++ b/gsrp_tdoa_hyperres.py @@ -8,9 +8,6 @@ import scipy.signal as sg import soundfile as sf from numpy.fft import rfft, irfft from scipy.signal.windows import tukey -from sklearn.linear_model import LinearRegression -from sklearn.pipeline import Pipeline -from sklearn.preprocessing import PolynomialFeatures from gsrp_smart_util import * @@ -104,6 +101,10 @@ def corr(data, pos, w_size, max_tdoa, decimate=1, mode='prepare', hyper=True, ve tdoas = np.zeros((len(pos), num_channel_pairs + 2), np.float32) if hyper: # prepare hyper res + from sklearn.linear_model import LinearRegression + from sklearn.pipeline import Pipeline + from sklearn.preprocessing import PolynomialFeatures + tdoas2 = np.zeros((len(pos), num_channel_pairs + 2), np.float32) poly = PolynomialFeatures(2) lin = LinearRegression()