Skip to content

Commit 3b2ab1e

Browse files
author
Vincent Lostanlen
committed
define five acoustic indices
1 parent 5304bd8 commit 3b2ab1e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

birdvoxpaint/indices.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import librosa
2+
import numpy as np
3+
4+
5+
def acoustic_complexity_index(S):
6+
spectrogram = np.abs(S)**2
7+
flux = np.abs(np.diff(spectrogram, axis=1))
8+
return np.sum(flux, axis=1)/np.sum(spectrogram, axis=1)
9+
10+
11+
def average_energy(S):
12+
spectrogram = np.abs(S)**2
13+
return np.sqrt(np.mean(spectrogram, axis=1))
14+
15+
16+
def entropy_based_concentration(S):
17+
spectrogram = np.abs(S)**2
18+
entropy = np.array([scipy.stats.entropy(row) for row in spectrogram])
19+
return (1 - entropy/np.log(spectrogram.shape[1]))
20+
21+
22+
def maximum_energy(S):
23+
spectrogram = np.abs(S)**2
24+
return np.max(spectrogram, axis=1)
25+
26+
27+
def maximum_flux(S):
28+
spectrogram = np.abs(S)**2
29+
flux = np.abs(np.diff(spectrogram, axis=1))
30+
return np.max(flux, axis=1)

0 commit comments

Comments
 (0)