1515import importlib
1616
1717sys .path .append (os .path .dirname (os .path .dirname (os .path .realpath (__file__ ))))
18- from lib import get_srcrepobindirs
18+ from lib import get_srcrepobindirs , load_audio_read_plugin
1919
2020def parse_model_file (modelstr ):
2121 filepath , filename = os .path .split (modelstr )
@@ -83,15 +83,6 @@ def isused(sound):
8383 return np .where ([x ['file' ]== sound ['file' ] and x ['ticks' ]== sound ['ticks' ] \
8484 for x in used_sounds ])[0 ]
8585
86- def trim_ext (wavfile ):
87- if len (audio_read_rec2ch (audio_read_strip_rec (wavfile ))) > 1 :
88- tmp = wavfile .split ('-' )
89- withext , rec = '-' .join (tmp [:- 1 ]), tmp [- 1 ]
90- withoutext = os .path .splitext (withext )[0 ]+ '-' + rec
91- else :
92- withoutext = os .path .splitext (wavfile )[0 ]
93- return withoutext
94-
9586def save_annotations ():
9687 global nrecent_annotations
9788 if nrecent_annotations > 0 :
@@ -259,7 +250,7 @@ def init(_bokeh_document, _configuration_file, _use_aitch):
259250 global context_width_sec0 , context_offset_sec0
260251 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
261252 global user_changed_recording , user_copied_parameters
262- global audio_read , audio_read_exts , audio_read_rec2ch , audio_read_strip_rec
253+ global audio_read , audio_read_exts , audio_read_rec2ch , audio_read_strip_rec , trim_ext
263254 global video_read , detect_labels , doubleclick_annotation , context_data , context_data_istart , model , video_findfile
264255 global detect_parameters , doubleclick_parameters , model_parameters , cluster_parameters
265256
@@ -276,14 +267,8 @@ def init(_bokeh_document, _configuration_file, _use_aitch):
276267
277268 sys .path .insert (0 ,srcdir )
278269
279- sys .path .insert (0 ,os .path .dirname (audio_read_plugin ))
280- audio_read_module = importlib .import_module (os .path .basename (audio_read_plugin ))
281- audio_read_module .audio_read_init (** audio_read_plugin_kwargs )
282- def audio_read (wav_path , start_tic = None , stop_tic = None ):
283- return audio_read_module .audio_read (wav_path , start_tic , stop_tic , ** audio_read_plugin_kwargs )
284- def audio_read_exts (): return audio_read_module .audio_read_exts (** audio_read_plugin_kwargs )
285- def audio_read_rec2ch (wavfile ): return audio_read_module .audio_read_rec2ch (wavfile , ** audio_read_plugin_kwargs )
286- def audio_read_strip_rec (recfile ): return audio_read_module .audio_read_strip_rec (recfile , ** audio_read_plugin_kwargs )
270+ load_audio_read_plugin (audio_read_plugin , audio_read_plugin_kwargs )
271+ from lib import audio_read , audio_read_exts , audio_read_rec2ch , audio_read_strip_rec , trim_ext
287272
288273 sys .path .insert (0 ,os .path .dirname (video_read_plugin ))
289274 video_read_module = importlib .import_module (os .path .basename (video_read_plugin ))
0 commit comments