From 9066e7e4bcdaf4f962dfc78063d3cb82618d6f72 Mon Sep 17 00:00:00 2001
From: Stephane Chavin <stephanechvn@gmail.com>
Date: Tue, 9 May 2023 09:04:38 +0200
Subject: [PATCH] add_frequency

---
 get_time_detection.py => get_time_freq_detection.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
 rename get_time_detection.py => get_time_freq_detection.py (80%)

diff --git a/get_time_detection.py b/get_time_freq_detection.py
similarity index 80%
rename from get_time_detection.py
rename to get_time_freq_detection.py
index 8f101b2..bacfc0b 100644
--- a/get_time_detection.py
+++ b/get_time_freq_detection.py
@@ -14,6 +14,8 @@ def arg_directory(path):
 parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='TODO')
 parser.add_argument('-p','--path_to_data', type=arg_directory, help = 'Path of the folder that contain the .txt files',required=True)
 parser.add_argument('-d','--directory', type=arg_directory, help = 'Directory to wich the dataframe will be stored',required=True)
+parser.add_argument('-t','--duration', type = int, help = 'Duration of the spectrogram', required = True)
+parser.add_argument('-s','--SR', type = int, help = 'Sampling Rate of the spectrogram')
 args = parser.parse_args()
 
 annots = args.path_to_data
@@ -32,8 +34,8 @@ del df['index']
 df['idx'] = df.file.str.split('_').str[-1].str.split('.').str[0]
 df.file = df.file.str.rsplit('.',1).str[0]+'.wav'
 
-DUREE_SPECTRO = 8
-OVERLAP = 2
+DUREE_SPECTRO = args.duration
+SR = args.SR
 
 #put the classes here
 names = []
@@ -44,6 +46,9 @@ for j in range (len(df)):
 
 print('Calculating the positions','\n')
 df['midl'] = (df.x*8)+(df.idx.astype(int))
+df['freq_center'] = (1-df.y)*(SR/2)
+df['freq_min'] = df.freq_center - (df.h*(SR/2))/2
+df['freq_max'] = df.freq_center + (df.h*(SR/2))/2
 
 df.to_csv(os.path.join(outdir,str(out_file+'.csv')), index= False)
 print('saved as ',os.path.join(outdir,str(out_file+'.csv')))
-- 
GitLab