analyzeAudio 0.2.0__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. {analyzeaudio-0.2.0 → analyzeaudio-0.4.0}/PKG-INFO +337 -152
  2. {analyzeaudio-0.2.0 → analyzeaudio-0.4.0}/README.md +334 -151
  3. analyzeaudio-0.4.0/analyzeAudio/__init__.py +28 -0
  4. {analyzeaudio-0.2.0 → analyzeaudio-0.4.0}/analyzeAudio/_beDRY.py +9 -0
  5. {analyzeaudio-0.2.0 → analyzeaudio-0.4.0}/analyzeAudio/_misfit.py +6 -9
  6. analyzeaudio-0.4.0/analyzeAudio/_theSSOT.py +5 -0
  7. analyzeaudio-0.4.0/analyzeAudio/_theTypes.py +60 -0
  8. {analyzeaudio-0.2.0 → analyzeaudio-0.4.0}/analyzeAudio/analyze.py +34 -42
  9. analyzeaudio-0.4.0/analyzeAudio/analyzersUseFilename/__init__.py +46 -0
  10. analyzeaudio-0.4.0/analyzeAudio/analyzersUseFilename/_aspectralstats.py +698 -0
  11. analyzeaudio-0.4.0/analyzeAudio/analyzersUseFilename/_astats.py +1140 -0
  12. analyzeaudio-0.4.0/analyzeAudio/analyzersUseFilename/_ebur128.py +412 -0
  13. analyzeaudio-0.2.0/analyzeAudio/pythonator.py → analyzeaudio-0.4.0/analyzeAudio/analyzersUseFilename/_pythonator.py +1 -1
  14. analyzeaudio-0.4.0/analyzeAudio/analyzersUseFilename/_wideRange.py +91 -0
  15. analyzeaudio-0.4.0/analyzeAudio/analyzersUseSpectrogram.py +456 -0
  16. analyzeaudio-0.4.0/analyzeAudio/analyzersUseTensor.py +154 -0
  17. {analyzeaudio-0.2.0 → analyzeaudio-0.4.0}/analyzeAudio/analyzersUseWaveform.py +146 -138
  18. analyzeaudio-0.4.0/analyzeAudio/contestsSpectrogram.py +235 -0
  19. analyzeaudio-0.2.0/analyzeAudio/analyzersUseTensor.py → analyzeaudio-0.4.0/analyzeAudio/contestsTensor.py +209 -363
  20. analyzeaudio-0.4.0/analyzeAudio/contestsTensorSpectrogram.py +203 -0
  21. {analyzeaudio-0.2.0 → analyzeaudio-0.4.0}/analyzeAudio/ffmpeg.py +0 -1
  22. analyzeaudio-0.2.0/analyzeAudio/audioAspectsRegistry.py → analyzeaudio-0.4.0/analyzeAudio/registry.py +96 -9
  23. {analyzeaudio-0.2.0 → analyzeaudio-0.4.0}/analyzeAudio.egg-info/PKG-INFO +337 -152
  24. analyzeaudio-0.4.0/analyzeAudio.egg-info/SOURCES.txt +46 -0
  25. analyzeaudio-0.4.0/analyzeAudio.egg-info/entry_points.txt +4 -0
  26. {analyzeaudio-0.2.0 → analyzeaudio-0.4.0}/analyzeAudio.egg-info/requires.txt +2 -0
  27. {analyzeaudio-0.2.0 → analyzeaudio-0.4.0}/analyzeAudio.egg-info/top_level.txt +0 -1
  28. {analyzeaudio-0.2.0 → analyzeaudio-0.4.0}/pyproject.toml +10 -11
  29. analyzeaudio-0.4.0/tests/__init__.py +14 -0
  30. analyzeaudio-0.4.0/tests/_theSSOT.py +21 -0
  31. analyzeaudio-0.4.0/tests/_theTypes.py +80 -0
  32. analyzeaudio-0.4.0/tests/conftest.py +183 -0
  33. analyzeaudio-0.4.0/tests/dataSamples/SpeakSoftly_BrokenMan60sec/expected.py +313 -0
  34. analyzeaudio-0.4.0/tests/dataSamples/__init__.py +0 -0
  35. analyzeaudio-0.4.0/tests/dataSamples/expected.py +1837 -0
  36. analyzeaudio-0.4.0/tests/test_analyzersUseFilename.py +239 -0
  37. analyzeaudio-0.4.0/tests/test_analyzersUseSpectrogram.py +72 -0
  38. analyzeaudio-0.4.0/tests/test_analyzersUseTensor.py +34 -0
  39. analyzeaudio-0.4.0/tests/test_analyzersUseTensorSpectrogram.py +0 -0
  40. analyzeaudio-0.4.0/tests/test_analyzersUseWaveform.py +43 -0
  41. analyzeaudio-0.4.0/tests/test_contestsSpectrogram.py +50 -0
  42. analyzeaudio-0.4.0/tests/test_contestsTensor.py +113 -0
  43. analyzeaudio-0.4.0/tests/test_contestsTensorSpectrogram.py +92 -0
  44. analyzeaudio-0.2.0/analyzeAudio/__init__.py +0 -26
  45. analyzeaudio-0.2.0/analyzeAudio/_theTypes.py +0 -20
  46. analyzeaudio-0.2.0/analyzeAudio/analyzersUseFilename.py +0 -2121
  47. analyzeaudio-0.2.0/analyzeAudio/analyzersUseSpectrogram.py +0 -359
  48. analyzeaudio-0.2.0/analyzeAudio/analyzersUseTensorSpectrogram.py +0 -189
  49. analyzeaudio-0.2.0/analyzeAudio.egg-info/SOURCES.txt +0 -30
  50. analyzeaudio-0.2.0/analyzeAudio.egg-info/entry_points.txt +0 -2
  51. analyzeaudio-0.2.0/tests/conftest.py +0 -54
  52. analyzeaudio-0.2.0/tests/test_analyzersUseFilename.py +0 -379
  53. analyzeaudio-0.2.0/tests/test_analyzersUseSpectrogram.py +0 -87
  54. analyzeaudio-0.2.0/tests/test_analyzersUseTensor.py +0 -192
  55. analyzeaudio-0.2.0/tests/test_analyzersUseTensorSpectrogram.py +0 -59
  56. analyzeaudio-0.2.0/tests/test_analyzersUseWaveform.py +0 -84
  57. {analyzeaudio-0.2.0 → analyzeaudio-0.4.0}/LICENSE +0 -0
  58. {analyzeaudio-0.2.0 → analyzeaudio-0.4.0}/analyzeAudio/py.typed +0 -0
  59. {analyzeaudio-0.2.0 → analyzeaudio-0.4.0}/analyzeAudio.egg-info/dependency_links.txt +0 -0
  60. {analyzeaudio-0.2.0 → analyzeaudio-0.4.0}/setup.cfg +0 -0
  61. {analyzeaudio-0.2.0/tests → analyzeaudio-0.4.0/tests/dataSamples/SpeakSoftly_BrokenMan60sec}/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: analyzeAudio
3
- Version: 0.2.0
3
+ Version: 0.4.0
4
4
  Summary: Measure one or more aspects of one or more audio files.
5
5
  Author-email: Hunter Hogan <HunterHogan@pm.me>
6
6
  License-Expression: CC-BY-NC-4.0
@@ -34,6 +34,8 @@ Requires-Python: >=3.10
34
34
  Description-Content-Type: text/markdown
35
35
  License-File: LICENSE
36
36
  Requires-Dist: auraloss
37
+ Requires-Dist: hunterHearsPy>=1.0.3
38
+ Requires-Dist: hunterMakesPy>=0.7.0
37
39
  Requires-Dist: librosa
38
40
  Requires-Dist: numpy
39
41
  Requires-Dist: scipy
@@ -57,212 +59,396 @@ Measure one or more aspects of one or more audio files.
57
59
 
58
60
  Some options to [download FFmpeg and FFprobe](https://www.ffmpeg.org/download.html) at ffmpeg.org.
59
61
 
62
+ ### Install FFmpeg on Google Colab
63
+
64
+ ```python
65
+ from analyzeAudio.ffmpeg import verifyFFmpegColab
66
+ verifyFFmpegColab()
67
+ ```
68
+
60
69
  [![pip install analyzeAudio](https://img.shields.io/badge/pip_install-analyzeAudio-gray.svg?labelColor=blue)](https://pypi.org/project/analyzeAudio/)
61
70
  [![uv add analyzeAudio](https://img.shields.io/badge/uv_add-analyzeAudio-gray.svg?labelColor=blue)](https://pypi.org/project/analyzeAudio/)
62
71
 
63
- ## Some ways to use this package
72
+ ## What is in the package
73
+
74
+ `analyzeAudio` provides two user-facing kinds of audio analysis.
75
+
76
+ - Audio aspects measure one audio file.
77
+ - Audio contests compare two audio files, waveforms, tensors, or spectrograms.
78
+
79
+ The main user workflows are:
80
+
81
+ | What you want | Use |
82
+ | -------------------------------------------------------- | ----------------------------------------------- |
83
+ | One value for each selected measurement on one file | `analyzeAudioFile` |
84
+ | The same selected measurements for many files | `analyzeAudioListPathFilenames` |
85
+ | A TSV, CSV, or other delimited output file | `dataTabularTOpathFilenameDelimited` |
86
+ | One specific measurement or detailed frame data | Import a direct analyzer function |
87
+ | One comparison score between two files | Import a filename contest function |
88
+ | One comparison score between two tensors or spectrograms | Import a tensor or spectrogram contest function |
89
+
90
+ ### One-file measurements
91
+
92
+ Use these names with `analyzeAudioFile` or
93
+ `analyzeAudioListPathFilenames`. Names are case-sensitive.
94
+
95
+ Loudness and true peak:
96
+
97
+ | Name | What it measures |
98
+ | ------------------------- | ------------------------------- |
99
+ | `LUFS integrated` | Whole-file integrated loudness. |
100
+ | `LUFS momentary maximum` | Maximum momentary loudness. |
101
+ | `LUFS short-term maximum` | Maximum short-term loudness. |
102
+ | `LUFS loudness range` | Loudness range. |
103
+ | `LUFS low` | Low loudness range boundary. |
104
+ | `LUFS high` | High loudness range boundary. |
105
+ | `true_peak maximum` | Maximum true peak level. |
106
+
107
+ Signal level, dynamics, and samples:
108
+
109
+ | Name | What it measures |
110
+ | ----------------------------- | ------------------------------------------------ |
111
+ | `RMS_level overall` | Overall RMS level. |
112
+ | `RMS_peak overall` | Overall RMS peak. |
113
+ | `RMS_trough overall` | Overall RMS trough. |
114
+ | `RMS_difference overall` | Overall RMS difference between adjacent samples. |
115
+ | `Peak_level overall` | Overall peak level. |
116
+ | `Peak_count total` | Total detected peak count. |
117
+ | `Abs_Peak_count total` | Total absolute peak count. |
118
+ | `Crest_factor mean` | Mean crest factor. |
119
+ | `Dynamic_range overall` | Overall dynamic range. |
120
+ | `DC_offset mean` | Mean DC offset. |
121
+ | `Bit_depth mean` | Mean detected bit depth. |
122
+ | `Entropy mean` | Mean signal entropy. |
123
+ | `Flat_factor mean` | Mean flat factor. |
124
+ | `Max_difference overall` | Maximum sample difference. |
125
+ | `Max_level overall` | Maximum sample level. |
126
+ | `Mean_difference mean` | Mean adjacent-sample difference. |
127
+ | `Min_difference overall` | Minimum sample difference. |
128
+ | `Min_level overall` | Minimum sample level. |
129
+ | `Noise_floor overall` | Overall noise floor. |
130
+ | `Noise_floor_count total` | Total noise-floor count. |
131
+ | `Number_of_samples total` | Total samples. |
132
+ | `Zero_crossings total` | Total zero crossings. |
133
+ | `Zero_crossings_rate overall` | Overall zero-crossing rate. |
134
+
135
+ Spectral measurements:
136
+
137
+ | Name | What it measures |
138
+ | ----------------------------- | ---------------------------------------------------- |
139
+ | `Power spectral density mean` | Mean power spectral density. |
140
+ | `Spectral centroid mean` | Mean spectral center of mass from filename analysis. |
141
+ | `Spectral crest mean` | Mean spectral crest. |
142
+ | `Spectral decrease mean` | Mean spectral decrease. |
143
+ | `Spectral entropy mean` | Mean spectral entropy. |
144
+ | `Spectral flatness mean` | Mean spectral flatness from filename analysis. |
145
+ | `Spectral flux mean` | Mean spectral flux. |
146
+ | `Spectral kurtosis mean` | Mean spectral kurtosis. |
147
+ | `Spectral rolloff mean` | Mean spectral rolloff. |
148
+ | `Spectral skewness mean` | Mean spectral skewness. |
149
+ | `Spectral slope mean` | Mean spectral slope. |
150
+ | `Spectral spread mean` | Mean spectral spread. |
151
+ | `Spectral variance mean` | Mean spectral variance. |
152
+ | `Spectral Bandwidth mean` | Mean librosa spectral bandwidth. |
153
+ | `Spectral Centroid mean` | Mean librosa spectral centroid. |
154
+ | `Spectral Contrast mean` | Mean librosa spectral contrast. |
155
+ | `Spectral Flatness mean` | Mean librosa spectral flatness ratio. |
156
+ | `Spectral Flatness dB mean` | Mean librosa spectral flatness in decibels. |
157
+ | `Chromagram mean` | Mean chroma energy across pitch classes. |
158
+
159
+ Waveform, rhythm, and speech measurements:
160
+
161
+ | Name | What it measures |
162
+ | ------------------------- | ----------------------------------------------------- |
163
+ | `RMS Waveform mean` | Mean waveform RMS amplitude. |
164
+ | `RMS Waveform dB mean` | Mean waveform RMS level in decibels. |
165
+ | `Tempogram mean` | Mean tempogram value. |
166
+ | `Tempo mean` | Mean estimated tempo. |
167
+ | `Zero Crossing Rate mean` | Mean waveform zero-crossing rate. |
168
+ | `SRMR mean` | Mean speech-to-reverberation modulation energy ratio. |
169
+
170
+ Some names intentionally differ only by capitalization or wording. For example,
171
+ `Spectral flatness mean` and `Spectral Flatness mean` are different
172
+ measurements. Use the exact name from the table.
173
+
174
+ ### Measure one file
175
+
176
+ ```python
177
+ from analyzeAudio import analyzeAudioFile
178
+
179
+ listAspectNames = [
180
+ "LUFS integrated",
181
+ "true_peak maximum",
182
+ "RMS_level overall",
183
+ "Spectral Flatness mean",
184
+ "Zero Crossing Rate mean",
185
+ ]
186
+
187
+ listValues = analyzeAudioFile("voice.wav", listAspectNames)
188
+ measurements = dict(zip(listAspectNames, listValues, strict=True))
189
+ print(measurements)
190
+ ```
64
191
 
65
- `analyzeAudio` works at five practical levels: audio path, waveform array, spectrogram array,
66
- waveform tensor, and magnitude-spectrogram tensor. The top-level API is the quickest way to ask
67
- for named measurements from audio paths. The lower-level modules are there when you already have
68
- decoded audio in memory, want the full array or tensor instead of one summary float, or want to
69
- call direct comparison and loss analyzers yourself.
192
+ `analyzeAudioFile` returns one value for each requested name, in the same order.
193
+ If a requested name is unavailable, that value is `"not found"`.
70
194
 
71
- ### Top-level exports you will probably reach for first
195
+ ### Measure many files
72
196
 
73
- | Export | Purpose |
74
- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
75
- | `analyzeAudioFile(pathFilename, listAspectNames)` | Analyze one audio path and return one result per requested registered aspect name. |
76
- | `analyzeAudioListPathFilenames(listPathFilenames, listAspectNames, CPUlimit=None)` | Analyze many audio paths in parallel and return one completed row per audio path. |
77
- | `getListAvailableAudioAspects()` | Return the sorted list of registered aspect names. |
78
- | `audioAspects` | Registry of `aspect name -> analyzer callable + required parameter names`. |
79
- | `truncateTensors(listTensors)` | Trim multiple tensors to the same trailing length before direct comparison. |
80
- | `dataTabularTOpathFilenameDelimited(...)` | Write batch results to a delimited text file. |
197
+ ```python
198
+ from pathlib import Path
199
+ from analyzeAudio import analyzeAudioListPathFilenames
81
200
 
82
- The package also re-exports the type aliases `Audio`, `Spectrogram`, `SpectrogramMagnitude`, and
83
- `SpectrogramPower` so downstream code can annotate the same representations the analyzers expect.
201
+ listPathFilenames = tuple(Path("audio").glob("*.wav"))
202
+ listAspectNames = [
203
+ "LUFS integrated",
204
+ "LUFS loudness range",
205
+ "true_peak maximum",
206
+ ]
84
207
 
85
- ### Choose the module that matches the representation you already have
208
+ rows = analyzeAudioListPathFilenames(
209
+ listPathFilenames,
210
+ listAspectNames,
211
+ CPUlimit=4,
212
+ )
86
213
 
87
- | If you already have... | Reach for... | What you get |
88
- | ------------------------------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------ |
89
- | one or more audio paths | top-level API or `analyzersUseFilename` | named single-path measurements, paired-path comparisons, FFprobe/FFmpeg-derived arrays, loudness |
90
- | waveform `numpy.ndarray` + `sampleRate` | `analyzersUseWaveform` | tempogram, RMS, tempo, and zero-crossing arrays or their mean summaries |
91
- | spectrogram magnitude/power `numpy.ndarray` | `analyzersUseSpectrogram` | chroma and spectral-descriptor arrays or their mean summaries |
92
- | waveform `torch.Tensor` | `analyzersUseTensor` | SRMR, logWMSE, source-separation scores, and waveform/STFT-domain loss analyzers |
93
- | magnitude spectrogram `torch.Tensor` | `analyzersUseTensorSpectrogram` | spectrogram-magnitude comparison losses such as spectral convergence and STFT-magnitude distance |
214
+ for row in rows:
215
+ print(row)
216
+ ```
94
217
 
95
- The registry spans more than single-path measurements. Some registered names are convenient
96
- single-audio measurements, some are paired-path comparisons, some expect waveform tensors, and some
97
- expect magnitude spectrogram tensors.
218
+ Each row starts with the analyzed filename, followed by the requested values.
219
+ Rows are returned as files finish, so row order can differ from input order.
98
220
 
99
- ### Use `analyzeAudioFile` to measure registered single-audio aspects from one path
221
+ ### Save measurements
100
222
 
101
223
  ```python
102
- from analyzeAudio import analyzeAudioFile
224
+ from analyzeAudio import (
225
+ analyzeAudioListPathFilenames,
226
+ dataTabularTOpathFilenameDelimited,
227
+ )
103
228
 
104
- listAspectNames = [
105
- 'LUFS integrated',
106
- 'RMS peak',
107
- 'SRMR mean',
108
- 'Spectral Flatness mean',
109
- ]
229
+ listAspectNames = ["LUFS integrated", "true_peak maximum"]
230
+ rows = analyzeAudioListPathFilenames(["one.wav", "two.wav"], listAspectNames)
110
231
 
111
- listMeasurements = analyzeAudioFile(pathFilename, listAspectNames)
112
- dictionaryMeasurements = dict(zip(listAspectNames, listMeasurements, strict=True))
232
+ dataTabularTOpathFilenameDelimited(
233
+ "measurements.tsv",
234
+ rows,
235
+ ["pathFilename", *listAspectNames],
236
+ )
113
237
  ```
114
238
 
115
- `analyzeAudioFile` reads one audio path, prepares shared intermediate representations, and lets
116
- registered analyzers reuse those representations. Under the hood that means one call can support
117
- measurements that need the raw waveform, `sampleRate`, a `torch.Tensor` waveform, a complex STFT,
118
- spectrogram magnitude, or spectrogram power.
239
+ For CSV output, use a comma delimiter:
119
240
 
120
- `analyzeAudioFile` preserves the order of `listAspectNames`. If a requested aspect name is not
121
- registered, the matching return entry is `'not found'`.
241
+ ```python
242
+ dataTabularTOpathFilenameDelimited(
243
+ "measurements.csv",
244
+ rows,
245
+ ["pathFilename", *listAspectNames],
246
+ delimiterOutput=",",
247
+ )
248
+ ```
122
249
 
123
- Registered names are case-sensitive, and some intentionally similar names come from different
124
- analysis routes. For example, `Spectral Flatness mean` and `Spectral flatness mean` are different
125
- registered names, and so are `Zero-crossing rate mean` and `Zero-crossings rate`.
250
+ ### Get detailed arrays
126
251
 
127
- Some registered names require inputs that cannot come from a single audio path alone. Examples
128
- include `SI-SDR mean`, `LogWMSE`, `L1SNRDB`, and `SpectralConvergenceLoss`. For those, inspect the
129
- registry and call the analyzer directly.
252
+ Summary names usually return one number. Direct analyzer functions without
253
+ summary words usually return the per-frame, per-channel, or per-band values.
130
254
 
131
- ### Use `analyzeAudioListPathFilenames` to batch single-audio measurements across many paths
255
+ ```python
256
+ from analyzeAudio.analyzersUseFilename import (
257
+ analyzeLUFSIntegratedOverall,
258
+ analyzeLUFSMomentary,
259
+ )
260
+
261
+ integrated = analyzeLUFSIntegratedOverall("voice.wav")
262
+ momentaryFrames = analyzeLUFSMomentary("voice.wav")
263
+ ```
264
+
265
+ ### Use audio already loaded in Python
266
+
267
+ Waveform analyzers accept waveform samples shaped as channels by samples.
132
268
 
133
269
  ```python
134
- from analyzeAudio import analyzeAudioListPathFilenames, dataTabularTOpathFilenameDelimited
270
+ import numpy
271
+ import soundfile
272
+ from analyzeAudio.analyzersUseWaveform import (
273
+ analyzeRMSWaveformMean,
274
+ analyzeTempoMean,
275
+ analyzeZeroCrossingRateMean,
276
+ )
135
277
 
136
- listAspectNames = ['LUFS integrated', 'Spectral Flatness mean']
137
- rowsListFilenameAspectValues = analyzeAudioListPathFilenames(listPathFilenames, listAspectNames)
278
+ with soundfile.SoundFile("voice.wav") as audioFile:
279
+ sampleRate = audioFile.samplerate
280
+ waveform = audioFile.read(dtype="float32", always_2d=True).astype(numpy.float32).T
138
281
 
139
- dataTabularTOpathFilenameDelimited(
140
- pathFilenameOutput,
141
- rowsListFilenameAspectValues,
142
- ['pathFilename', *listAspectNames],
282
+ rms = analyzeRMSWaveformMean(waveform)
283
+ tempo = analyzeTempoMean(waveform, sampleRate)
284
+ zeroCrossingRate = analyzeZeroCrossingRateMean(waveform)
285
+ ```
286
+
287
+ Spectrogram analyzers accept magnitude or power spectrograms.
288
+
289
+ ```python
290
+ import librosa
291
+ import numpy
292
+ from analyzeAudio.analyzersUseSpectrogram import (
293
+ analyzeChromagramMean,
294
+ analyzeSpectralCentroidMean,
143
295
  )
296
+
297
+ spectrogram = librosa.stft(waveform)
298
+ spectrogramMagnitude = numpy.absolute(spectrogram)
299
+ spectrogramPower = spectrogramMagnitude**2
300
+
301
+ spectralCentroid = analyzeSpectralCentroidMean(spectrogramMagnitude)
302
+ chromagram = analyzeChromagramMean(spectrogramPower, sampleRate)
144
303
  ```
145
304
 
146
- Each returned row starts with the audio path converted to POSIX text, followed by the requested
147
- values. The rows are returned in worker-completion order rather than the original input order.
148
- Use `CPUlimit` when you want to cap the worker count explicitly.
305
+ ### Two-input comparisons
149
306
 
150
- ### Use `getListAvailableAudioAspects` and `audioAspects` to inspect the registry or call an analyzer directly
307
+ Filename contests compare two audio files:
308
+
309
+ | Function | What it compares |
310
+ | -------------------- | ------------------------------------------------ |
311
+ | `analyzePSNRmean` | Mean peak signal-to-noise ratio. |
312
+ | `analyzeSDRmean` | Mean signal-to-distortion ratio. |
313
+ | `analyzeSI_SDRmean` | Mean scale-invariant signal-to-distortion ratio. |
314
+ | `analyzeKPSNRmean` | Bounded score from PSNR. |
315
+ | `analyzeKSDRmean` | Bounded score from SDR. |
316
+ | `analyzeKSI_SDRmean` | Bounded score from SI-SDR. |
151
317
 
152
318
  ```python
153
- from analyzeAudio import audioAspects, getListAvailableAudioAspects
319
+ from analyzeAudio.analyzersUseFilename import (
320
+ analyzePSNRmean,
321
+ analyzeSDRmean,
322
+ analyzeSI_SDRmean,
323
+ )
154
324
 
155
- print(getListAvailableAudioAspects())
156
- print(audioAspects['Chromagram mean']['analyzerParameters'])
157
- print(audioAspects['SI-SDR mean']['analyzerParameters'])
158
- print(audioAspects['LogWMSE']['analyzerParameters'])
325
+ pathReference = "reference.wav"
326
+ pathEstimate = "estimate.wav"
327
+
328
+ psnr = analyzePSNRmean(pathReference, pathEstimate)
329
+ sdr = analyzeSDRmean(pathReference, pathEstimate)
330
+ si_sdr = analyzeSI_SDRmean(pathReference, pathEstimate)
331
+ ```
332
+
333
+ Tensor waveform contests usually compare two PyTorch waveform tensors:
334
+
335
+ | Function | What it compares |
336
+ | --------------------------------- | --------------------------------------------------------------------------------------- |
337
+ | `analyzeL1SNRMean` | Mean L1 signal-to-noise ratio. |
338
+ | `analyzeL1SNRDBMean` | Mean L1 signal-to-noise ratio in decibels. |
339
+ | `analyzeMultiL1SNRDBMean` | Multi-source L1 SNR in decibels. |
340
+ | `analyzeSTFTL1SNRDBMean` | STFT-domain L1 SNR in decibels. |
341
+ | `analyzeLogWMSEMean` | Mean log weighted MSE audio-quality score for reference, estimate, and mixture tensors. |
342
+ | `analyzeDCLoss` | DC loss. |
343
+ | `analyzeESRLoss` | Error-to-signal ratio loss. |
344
+ | `analyzeLogCoshLoss` | Log-cosh loss. |
345
+ | `analyzeSNRLoss` | Signal-to-noise ratio loss. |
346
+ | `analyzeSISDRLoss` | Scale-invariant SDR loss. |
347
+ | `analyzeSDSDRLoss` | Scale-dependent SDR loss. |
348
+ | `analyzeSTFTLoss` | STFT loss. |
349
+ | `analyzeMelSTFTLoss` | Mel-STFT loss. |
350
+ | `analyzeChromaSTFTLoss` | Chroma-STFT loss. |
351
+ | `analyzeMultiResolutionSTFTLoss` | Multi-resolution STFT loss. |
352
+ | `analyzeRandomResolutionSTFTLoss` | Random-resolution STFT loss. |
353
+ | `analyzeSumAndDifferenceSTFTLoss` | Sum-and-difference STFT loss. |
159
354
 
160
- SI_SDR_channelsMean = audioAspects['SI-SDR mean']['analyzer'](
161
- pathFilenameAudioFile,
162
- pathFilenameDifferentAudioFile,
355
+ ```python
356
+ from analyzeAudio.contestsTensor import (
357
+ analyzeL1SNRDBMean,
358
+ analyzeMultiResolutionSTFTLoss,
163
359
  )
360
+
361
+ l1snrdb = analyzeL1SNRDBMean(tensorReference, tensorEstimate)
362
+ mrstft = analyzeMultiResolutionSTFTLoss(tensorReference, tensorEstimate)
164
363
  ```
165
364
 
166
- Use `audioAspects[name]['analyzerParameters']` first. It tells you whether the registered name
167
- expects one audio path, two audio paths, waveform tensors, a reference-estimate-mixture triple, or
168
- spectrogram magnitudes.
169
-
170
- That is the quickest way to discover whether a name is meant for the high-level single-audio API or
171
- for direct invocation.
172
-
173
- ### Use the lower-level modules when you want the actual analyzer instead of one registry float
174
-
175
- These are the actual analyzers, organized by the representation they consume.
176
-
177
- - `analyzeAudio.analyzersUseFilename`
178
- - paired-path comparison metrics: `getPSNRmean`, `getSDRmean`, `getSI_SDRmean`
179
- - framewise spectral arrays with matching mean wrappers: `analyzeSpectralCentroid`,
180
- `analyzeSpectralCrest`, `analyzeSpectralDecrease`, `analyzeSpectralEntropy`,
181
- `analyzeSpectralFlatness`, `analyzeSpectralFlux`, `analyzeSpectralKurtosis`,
182
- `analyzeSpectralMean`, `analyzeSpectralRolloff`, `analyzeSpectralSkewness`,
183
- `analyzeSpectralSlope`, `analyzeSpectralSpread`, `analyzeSpectralVariance`
184
- - file-level FFprobe `astats` scalars: `analyzeZero_crossings`, `analyzeZero_crossings_rate`,
185
- `analyzeDCoffset`, `analyzeDynamicRange`, `analyzeSignalEntropy`, `analyzeNumber_of_samples`,
186
- `analyzePeak_level`, `analyzeRMS_level`, `analyzeCrest_factor`, `analyzeRMS_peak`,
187
- `analyzeAbs_Peak_count`, `analyzeBit_depth`, `analyzeFlat_factor`, `analyzeMax_difference`,
188
- `analyzeMax_level`, `analyzeMean_difference`, `analyzeMin_difference`, `analyzeMin_level`,
189
- `analyzeNoise_floor`, `analyzeNoise_floor_count`, `analyzePeak_count`,
190
- `analyzeRMS_difference`, `analyzeRMS_trough`
191
- - loudness and true-peak arrays plus scalar summaries: `analyzeTruePeak`,
192
- `analyzeLUFSMomentary`, `analyzeLUFSShortTerm`, `analyzeLUFSIntegrated`, `analyzeLRA`,
193
- `analyzeLUFSlow`, `analyzeLUFShigh`, plus the matching `...Overall` scalar functions
194
- - `analyzeAudio.analyzersUseWaveform`
195
- - raw arrays: `analyzeTempogram`, `analyzeRMS`, `analyzeTempo`, `analyzeZeroCrossingRate`
196
- - mean summaries: `analyzeTempogramMean`, `analyzeRMSMean`, `analyzeTempoMean`,
197
- `analyzeZeroCrossingRateMean`
198
- - `analyzeAudio.analyzersUseSpectrogram`
199
- - raw arrays: `analyzeChromagram`, `analyzeSpectralContrast`, `analyzeSpectralBandwidth`,
200
- `analyzeSpectralCentroid`, `analyzeSpectralFlatness`
201
- - mean summaries: `analyzeChromagramMean`, `analyzeSpectralContrastMean`,
202
- `analyzeSpectralBandwidthMean`, `analyzeSpectralCentroidMean`,
203
- `analyzeSpectralFlatnessMean`
204
- - `analyzeAudio.analyzersUseTensor`
205
- - reverberation and intelligibility: `analyzeSRMR`, `analyzeSRMRMean`
206
- - reference-estimate-mixture scoring: `analyzeLogWMSEMean`
207
- - source-separation scores: `analyzeL1SNRMean`, `analyzeL1SNRDBMean`,
208
- `analyzeMultiL1SNRDBMean`, `analyzeSTFTL1SNRDBMean`
209
- - waveform-domain and STFT-domain loss analyzers: `analyzeDCLoss`, `analyzeESRLoss`,
210
- `analyzeLogCoshLoss`, `analyzeSNRLoss`, `analyzeSISDRLoss`, `analyzeSDSDRLoss`,
211
- `analyzeSTFTLoss`, `analyzeMelSTFTLoss`, `analyzeChromaSTFTLoss`,
212
- `analyzeMultiResolutionSTFTLoss`, `analyzeRandomResolutionSTFTLoss`,
213
- `analyzeSumAndDifferenceSTFTLoss`
214
- - `analyzeAudio.analyzersUseTensorSpectrogram`
215
- - magnitude-spectrogram comparison analyzers: `analyzeSpectralConvergenceLoss`,
216
- `analyzeSTFTMagnitudeLoss`, `analyzeL1FrequencyLoss`
217
- - `analyzeAudio.ffmpeg`
218
- - environment check for Colab-style sessions: `verifyFFmpegColab`
219
-
220
- Several concept names exist in more than one module. That is intentional. For example,
221
- `Spectral flatness mean` comes from the filename-based FFprobe route, while `Spectral Flatness mean`
222
- comes from the spectrogram route. Similar names do not necessarily mean duplicate implementations.
365
+ `analyzeLogWMSEMean` also needs the original mixture and sample rate:
223
366
 
224
367
  ```python
225
- import numpy
226
- import soundfile
368
+ from analyzeAudio.contestsTensor import analyzeLogWMSEMean
369
+
370
+ logwmse = analyzeLogWMSEMean(
371
+ tensorReference,
372
+ tensorEstimate,
373
+ tensorMixture,
374
+ sampleRate,
375
+ )
376
+ ```
227
377
 
228
- from analyzeAudio.analyzersUseWaveform import analyzeTempogram
378
+ Tensor spectrogram contests compare two PyTorch magnitude spectrogram tensors:
229
379
 
230
- with soundfile.SoundFile(pathFilename) as readSoundFile:
231
- sampleRate = readSoundFile.samplerate
232
- waveform = readSoundFile.read(dtype='float32').astype(numpy.float32).T
380
+ | Function | What it compares |
381
+ | -------------------------------- | -------------------------- |
382
+ | `analyzeSpectralConvergenceLoss` | Spectral convergence loss. |
383
+ | `analyzeSTFTMagnitudeLoss` | STFT magnitude loss. |
384
+ | `analyzeL1FrequencyLoss` | L1 frequency score. |
233
385
 
234
- tempogram = analyzeTempogram(waveform, sampleRate)
386
+ ```python
387
+ from analyzeAudio.contestsTensorSpectrogram import (
388
+ analyzeSpectralConvergenceLoss,
389
+ analyzeSTFTMagnitudeLoss,
390
+ )
391
+
392
+ spectralConvergence = analyzeSpectralConvergenceLoss(
393
+ tensorSpectrogramMagnitudeReference,
394
+ tensorSpectrogramMagnitudeEstimate,
395
+ )
396
+ stftMagnitude = analyzeSTFTMagnitudeLoss(
397
+ tensorSpectrogramMagnitudeReference,
398
+ tensorSpectrogramMagnitudeEstimate,
399
+ )
235
400
  ```
236
401
 
402
+ NumPy spectrogram helpers compare two magnitude spectrograms:
403
+
404
+ | Function | What it returns |
405
+ | --------------------------- | -------------------------------------------------- |
406
+ | `analyzeBleedFullMelDB` | Arrays of added and missing mel-scaled dB content. |
407
+ | `analyzeBleedFullMelDBMean` | Two scores: `bleed` and `full`. |
408
+
237
409
  ```python
238
- from analyzeAudio.analyzersUseTensor import analyzeL1SNRDBMean
239
- from analyzeAudio.analyzersUseTensorSpectrogram import analyzeSpectralConvergenceLoss
410
+ from analyzeAudio.contestsSpectrogram import analyzeBleedFullMelDBMean
240
411
 
241
- valueScore = analyzeL1SNRDBMean(tensorAudioReference, tensorAudioEstimate)
242
- valueLoss = analyzeSpectralConvergenceLoss(tensorMagnitudeReference, tensorMagnitudeEstimate)
412
+ bleedFull = analyzeBleedFullMelDBMean(
413
+ spectrogramMagnitudeReference,
414
+ spectrogramMagnitudeEstimate,
415
+ )
416
+ print(bleedFull.bleed, bleedFull.full)
243
417
  ```
244
418
 
245
- ### Use `truncateTensors` when you want the aligned tensors yourself
419
+ ### Exact-name checks
246
420
 
247
- Most tensor comparison analyzers already trim inputs internally. `truncateTensors` is there for the
248
- times when you want the aligned tensors yourself before reusing them across several metrics.
421
+ The tables above describe what is in the package. These helpers are available
422
+ when you want a copyable list from the installed version:
249
423
 
250
424
  ```python
251
- from analyzeAudio import truncateTensors
425
+ from analyzeAudio import getListAvailableAudioAspects, getListAvailableAudioContests
252
426
 
253
- tensorAudioReference, tensorAudioEstimate = truncateTensors([
254
- tensorAudioReference,
255
- tensorAudioEstimate,
256
- ])
427
+ print(getListAvailableAudioAspects())
428
+ print(getListAvailableAudioContests())
257
429
  ```
258
430
 
259
- ### Use `whatMeasurements` to list registered measurements from the command line
431
+ The terminal commands are:
260
432
 
261
- ```sh
262
- whatMeasurements
433
+ ```powershell
434
+ whatAspects
435
+ whatContests
263
436
  ```
264
437
 
265
- This prints the same sorted registry names returned by `getListAvailableAudioAspects()`.
438
+ ## API standardization
439
+
440
+ A top priority for this package is a public API that is as standardized as
441
+ possible across filename, waveform, spectrogram, tensor, and contest analyzers.
442
+ The package wraps libraries with very different calling conventions, but analyzer
443
+ function signatures should model this package's dispatcher inputs, not every
444
+ underlying library option.
445
+
446
+ ## Wishlist
447
+
448
+ - [ ] Overhaul the semiotic system.
449
+ - [ ] Install FFmpeg in GitHub Actions for testing.
450
+ - [ ] Improve speed
451
+ - [ ] Sophisticated caching of large objects and un-hashable objects.
266
452
 
267
453
  ## Reference materials
268
454
 
@@ -412,7 +598,6 @@ This prints the same sorted registry names returned by `getListAvailableAudioAsp
412
598
  - Free author PDF: [Jonathan Le Roux](https://www.jonathanleroux.org/pdf/LeRoux2019ICASSP05sdr.pdf)
413
599
  - Implementations:
414
600
  - [Lightning-AI/torchmetrics](https://github.com/Lightning-AI/torchmetrics)
415
- - [FFprobe `asisdr` filter](https://ffmpeg.org/ffprobe-all.html#asisdr)
416
601
 
417
602
  ### Loudness Metering: EBU Mode Metering to Supplement Loudness Normalisation
418
603