Skip to content
Snippets Groups Projects

Main patch 623a

Closed Stephane Chavin requested to merge main-patch-623a into main
1 file
+ 6
1
Compare changes
  • Side-by-side
  • Inline
@@ -14,6 +14,8 @@ def arg_directory(path):
@@ -14,6 +14,8 @@ def arg_directory(path):
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='TODO')
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('-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('-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()
args = parser.parse_args()
annots = args.path_to_data
annots = args.path_to_data
@@ -33,7 +35,7 @@ df['idx'] = df.file.str.split('_').str[-1].str.split('.').str[0]
@@ -33,7 +35,7 @@ df['idx'] = df.file.str.split('_').str[-1].str.split('.').str[0]
df.file = df.file.str.rsplit('.',1).str[0]+'.wav'
df.file = df.file.str.rsplit('.',1).str[0]+'.wav'
DUREE_SPECTRO = 8
DUREE_SPECTRO = 8
OVERLAP = 2
SR = 22050
#put the classes here
#put the classes here
names = []
names = []
@@ -44,6 +46,9 @@ for j in range (len(df)):
@@ -44,6 +46,9 @@ for j in range (len(df)):
print('Calculating the positions','\n')
print('Calculating the positions','\n')
df['midl'] = (df.x*8)+(df.idx.astype(int))
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)
df.to_csv(os.path.join(outdir,str(out_file+'.csv')), index= False)
print('saved as ',os.path.join(outdir,str(out_file+'.csv')))
print('saved as ',os.path.join(outdir,str(out_file+'.csv')))
Loading