Skip to content
Snippets Groups Projects
Commit 9066e7e4 authored by Stephane Chavin's avatar Stephane Chavin
Browse files

add_frequency

parent f1d91af8
No related branches found
No related tags found
No related merge requests found
......@@ -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')))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment