Skip to content

Commit

Permalink
export clips
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Lostanlen committed Nov 21, 2018
1 parent 8724683 commit db0f859
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions birdvoxdetect/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ def process_file(filepath,
if export_clips:
clips_dir = get_output_path(
filepath, suffix + "_clips", output_dir=output_dir)
os.makedirs(clips_dir, exist_ok=True)

for t in th_peak_timestamps:
start = int(sr*np.round(t-0.5*clip_duration))
stop = int(sr*np.round(t+0.5*clip_duration))
audio_clip = audio[start:stop]
clip_path = get_output_path(
filepath,
suffix + "{:02.2f}.wav".format(t),
output_dir = clips_dir)
librosa.output.write_wav(clip_path, audio, sr)


def get_likelihood(audio, sr, frame_rate):
Expand Down

0 comments on commit db0f859

Please sign in to comment.