@@ -84,8 +84,14 @@ def save_annotations():
8484 fids = {}
8585 csvwriters = {}
8686 csvfiles_current = set ([])
87- for wavfile in set ([os .path .join (* x ['file' ]) for x in annotated_sounds if x ["label" ]!= "" ]):
88- csvfile = wavfile [:- 4 ]+ "-annotated-" + songexplorer_starttime + ".csv"
87+ wavfiles = set ()
88+ for sound in annotated_sounds :
89+ if not sound ["label" ]: continue
90+ wavfile = os .path .join (* sound ["file" ])
91+ wavfile_norec = '' .join (wavfile .split ('-' )[:- 1 ]) if len (audio_read_rec2ch ())> 1 else wavfile
92+ wavfiles |= set ([wavfile_norec ])
93+ for wavfile in wavfiles :
94+ csvfile = os .path .splitext (wavfile )[0 ]+ "-annotated-" + songexplorer_starttime + ".csv"
8995 annotated_csvfiles_all .add (csvfile )
9096 csvfiles_current .add (csvfile )
9197 fids [wavfile ] = open (os .path .join (V .groundtruth_folder .value , csvfile ),
@@ -98,7 +104,9 @@ def save_annotations():
98104 corrected_sounds = []
99105 for annotation in annotated_sounds :
100106 if annotation ['label' ]!= "" and not annotation ['label' ].isspace ():
101- csvwriters [os .path .join (* annotation ['file' ])].writerow (
107+ wavfile = os .path .join (* annotation ['file' ])
108+ wavfile_norec = '' .join (wavfile .split ('-' )[:- 1 ]) if len (audio_read_rec2ch ())> 1 else wavfile
109+ csvwriters [wavfile_norec ].writerow (
102110 [annotation ['file' ][1 ],
103111 annotation ['ticks' ][0 ], annotation ['ticks' ][1 ],
104112 'annotated' , annotation ['label' ]])
@@ -110,10 +118,15 @@ def save_annotations():
110118 x ['ticks' ][1 ], 'annotated' , x ['label' ]] \
111119 for x in corrected_sounds ], \
112120 columns = ['file' ,'start' ,'stop' ,'kind' ,'label' ])
113- for wavfile in set ([os .path .join (* x ['file' ]) for x in corrected_sounds ]):
121+ wavfiles = set ()
122+ for sound in corrected_sounds :
123+ wavfile = os .path .join (* sound ["file" ])
124+ wavfile_norec = '' .join (wavfile .split ('-' )[:- 1 ]) if len (audio_read_rec2ch ())> 1 else wavfile
125+ wavfiles |= set ([wavfile_norec ])
126+ for wavfile in wavfiles :
114127 wavdir , wavbase = os .path .split (wavfile )
115128 wavpath = os .path .join (V .groundtruth_folder .value , wavdir )
116- for csvbase in filter (lambda x : x .startswith (wavbase [: - 4 ]) and
129+ for csvbase in filter (lambda x : x .startswith (os . path . splitext ( wavbase )[ 0 ]) and
117130 x .endswith (".csv" ) and
118131 "-annotated" in x and
119132 songexplorer_starttime not in x ,
@@ -235,7 +248,8 @@ def init(_bokeh_document, _configuration_file, _use_aitch):
235248 global context_width_sec0 , context_offset_sec0
236249 global xcluster , ycluster , zcluster , ndcluster , tic2pix_max , snippet_width_pix , ilayer , ispecies , iword , inohyphen , ikind , nlayers , layers , species , words , nohyphens , kinds , used_labels , snippets_gap_sec , snippets_tic , snippets_gap_tic , snippets_decimate_by , snippets_pix , snippets_gap_pix , context_decimate_by , context_width_tic , context_offset_tic , context_sound , isnippet , xsnippet , ysnippet , file_nframes , context_midpoint_tic , ilabel , used_sounds , used_starts_sorted , used_stops , iused_stops_sorted , annotated_sounds , annotated_starts_sorted , annotated_stops , iannotated_stops_sorted , annotated_csvfiles_all , nrecent_annotations , clustered_sounds , clustered_activations , used_recording2firstsound , clustered_starts_sorted , clustered_stops , iclustered_stops_sorted , songexplorer_starttime , history_stack , history_idx , wizard , action , function , statepath , state , file_dialog_root , file_dialog_filter , nearest_sounds , status_ticker_queue , waitfor_job , dfs , remaining_isounds
237250 global user_changed_recording , user_copied_parameters
238- global audio_read , video_read , detect_labels , doubleclick_annotation , context_data , context_data_istart , model , video_findfile
251+ global audio_read , audio_read_exts , audio_read_rec2ch
252+ global video_read , detect_labels , doubleclick_annotation , context_data , context_data_istart , model , video_findfile
239253 global detect_parameters , doubleclick_parameters , model_parameters , cluster_parameters
240254
241255 bokeh_document = _bokeh_document
@@ -253,9 +267,11 @@ def init(_bokeh_document, _configuration_file, _use_aitch):
253267
254268 sys .path .insert (0 ,os .path .dirname (audio_read_plugin ))
255269 audio_read_module = importlib .import_module (os .path .basename (audio_read_plugin ))
270+ audio_read_module .audio_read_init (** audio_read_plugin_kwargs )
256271 def audio_read (wav_path , start_tic = None , stop_tic = None ):
257- return audio_read_module .audio_read (wav_path , start_tic , stop_tic ,
258- ** audio_read_plugin_kwargs )
272+ return audio_read_module .audio_read (wav_path , start_tic , stop_tic , ** audio_read_plugin_kwargs )
273+ def audio_read_exts (): return audio_read_module .audio_read_exts (** audio_read_plugin_kwargs )
274+ def audio_read_rec2ch (): return audio_read_module .audio_read_rec2ch (** audio_read_plugin_kwargs )
259275
260276 sys .path .insert (0 ,os .path .dirname (video_read_plugin ))
261277 video_read_module = importlib .import_module (os .path .basename (video_read_plugin ))
0 commit comments