diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2021-03-10 14:46:15 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2021-03-10 14:46:15 +0100 |
| commit | c84a675c07fd1997588794a26bf41c04f23c121e (patch) | |
| tree | d38758ab67c1d851069d6b9fd4b7da9934e3fb87 /animism-align/cli/app | |
| parent | e86e0a2f710d28c26a7457ab3fd35c88d2f937b1 (diff) | |
getting rid of basically all instances of bindActionCreators and mapDispatchToActions. hopefully never have to use these functions again
Diffstat (limited to 'animism-align/cli/app')
| -rw-r--r-- | animism-align/cli/app/peaks/extract.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/animism-align/cli/app/peaks/extract.py b/animism-align/cli/app/peaks/extract.py new file mode 100644 index 0000000..dda09d2 --- /dev/null +++ b/animism-align/cli/app/peaks/extract.py @@ -0,0 +1,31 @@ + +def extract_peaks(fp_in): + import os + import math + import librosa + import numpy + import json + + from app.settings import app_cfg + + if not os.path.exists(fp_in): + print(f"fp_in does not exist: {fp_in}") + return + + print(f"Loading {fp_in}") + y, sr = librosa.load(fp_in, sr=None) + + sr_10 = sr / 10 + steps = math.ceil(y.shape[0] / sr_10) + + peaks = numpy.ndarray(steps) + + for i in range(steps): + offset_start = math.floor(i * sr_10) + offset_end = math.ceil((i + 1) * sr_10) + slice = y[offset_start:offset_end] + peak = max(abs(slice.min()), slice.max()) + peaks[i] = float('%.3f' % peak) + # peaks[i * 2 + 1] = float('%.3f' % slice.max()) + + return peaks.tolist() |
