Skip to content

Commit

Permalink
Remove exceptions from birdsongrec.py
Browse files Browse the repository at this point in the history
This removes NotADirectory and FileNotFound errors raised by
`birdsongrec2annot` when `wavpath` doesn't exist or it can't find
the wav files in the specified `wavpath`, respectively.

My intent was to make sure the files were there,
if something else depended on them.
But this prevents someone from accessing the annotations
if they don't have the wav files.
Which is the opposite of the point of this package.
  • Loading branch information
NickleDave committed May 18, 2023
1 parent 14620cf commit c228040
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/crowsetta/birdsongrec.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ def birdsongrec2annot(annot_path='Annotation.xml', concat_seqs_into_songs=True,
else:
wavpath = Path(wavpath)

if not wavpath.exists():
raise NotADirectoryError(
"Value specified for 'wavpath' not recognized as an existing directory."
f"\nValue for 'wavpath' was: {wavpath}"
)

# `birdsong-recongition-dataset` also has a 'Sequence' class
# but it is slightly different from the `generic.Sequence` used by `crowsetta`
seq_list_xml = birdsongrec.parse_xml(annot_path,
Expand All @@ -88,11 +82,7 @@ def birdsongrec2annot(annot_path='Annotation.xml', concat_seqs_into_songs=True,

wav_filename = os.path.join(wavpath, seq_xml.wav_file)
wav_filename = os.path.abspath(wav_filename)
if not os.path.isfile(wav_filename):
raise FileNotFoundError(
f'.wav file {wav_filename} specified in '
f'annotation file {annot_path} is not found'
)

samp_freq = soundfile.info(wav_filename).samplerate
onsets_s = np.round(onset_inds / samp_freq, decimals=3)
offsets_s = np.round(offset_inds / samp_freq, decimals=3)
Expand Down

0 comments on commit c228040

Please sign in to comment.