analyzeAudio 0.0.14__py3-none-any.whl → 0.0.15__py3-none-any.whl

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.
@@ -40,7 +40,7 @@ def getSI_SDRmean(pathFilenameAlpha: str | PathLike[Any], pathFilenameBeta: str
40
40
  return SI_SDRmean
41
41
 
42
42
  @cachetools.cached(cache=cacheAudioAnalyzers)
43
- def ffprobeShotgunAndCache(pathFilename: str | PathLike[Any]) -> dict[str, float | numpy.ndarray]:
43
+ def ffprobeShotgunAndCache(pathFilename: str | PathLike[Any]) -> dict[str, float]:
44
44
  # for lavfi amovie/movie, the colons after driveLetter letters need to be escaped twice.
45
45
  pFn = pathlib.PureWindowsPath(pathFilename)
46
46
  lavfiPathFilename = pFn.drive.replace(":", "\\\\:")+pathlib.PureWindowsPath(pFn.root,pFn.relative_to(pFn.anchor)).as_posix()
@@ -63,14 +63,14 @@ def ffprobeShotgunAndCache(pathFilename: str | PathLike[Any]) -> dict[str, float
63
63
  stdoutFFprobe, _DISCARDstderr = systemProcessFFprobe.communicate()
64
64
  FFprobeStructured = pythonizeFFprobe(stdoutFFprobe.decode('utf-8'))[-1]
65
65
 
66
- dictionaryAspectsAnalyzed: dict[str, float | numpy.ndarray] = {}
66
+ dictionaryAspectsAnalyzed: dict[str, float] = {}
67
67
  if 'aspectralstats' in FFprobeStructured:
68
68
  for keyName in FFprobeStructured['aspectralstats']:
69
69
  # No matter how many channels, each keyName is `numpy.ndarray[tuple[int, int], numpy.dtype[numpy.float64]]`
70
70
  # where `tuple[int, int]` is (channel, frame)
71
71
  # NOTE (as of this writing) `registrar` can only understand the generic class `numpy.ndarray` and not more specific typing
72
- dictionaryAspectsAnalyzed[keyName] = FFprobeStructured['aspectralstats'][keyName]
73
- # dictionaryAspectsAnalyzed[keyName] = numpy.mean(FFprobeStructured['aspectralstats'][keyName]).astype(float)
72
+ # dictionaryAspectsAnalyzed[keyName] = FFprobeStructured['aspectralstats'][keyName]
73
+ dictionaryAspectsAnalyzed[keyName] = numpy.mean(FFprobeStructured['aspectralstats'][keyName]).astype(float)
74
74
  if 'r128' in FFprobeStructured:
75
75
  for keyName in FFprobeStructured['r128']:
76
76
  dictionaryAspectsAnalyzed[keyName] = FFprobeStructured['r128'][keyName][-1]
@@ -133,55 +133,55 @@ def analyzeLUFShigh(pathFilename: str | PathLike[Any]) -> float | None:
133
133
  return ffprobeShotgunAndCache(pathFilename).get('LRA.high')
134
134
 
135
135
  @registrationAudioAspect('Power spectral density')
136
- def analyzeMean(pathFilename: str | PathLike[Any]) -> numpy.ndarray:
136
+ def analyzeMean(pathFilename: str | PathLike[Any]) -> float | None:
137
137
  return ffprobeShotgunAndCache(pathFilename).get('mean')
138
138
 
139
139
  @registrationAudioAspect('Spectral variance')
140
- def analyzeVariance(pathFilename: str | PathLike[Any]) -> numpy.ndarray:
140
+ def analyzeVariance(pathFilename: str | PathLike[Any]) -> float | None:
141
141
  return ffprobeShotgunAndCache(pathFilename).get('variance')
142
142
 
143
143
  @registrationAudioAspect('Spectral centroid')
144
- def analyzeCentroid(pathFilename: str | PathLike[Any]) -> numpy.ndarray:
144
+ def analyzeCentroid(pathFilename: str | PathLike[Any]) -> float | None:
145
145
  return ffprobeShotgunAndCache(pathFilename).get('centroid')
146
146
 
147
147
  @registrationAudioAspect('Spectral spread')
148
- def analyzeSpread(pathFilename: str | PathLike[Any]) -> numpy.ndarray:
148
+ def analyzeSpread(pathFilename: str | PathLike[Any]) -> float | None:
149
149
  return ffprobeShotgunAndCache(pathFilename).get('spread')
150
150
 
151
151
  @registrationAudioAspect('Spectral skewness')
152
- def analyzeSkewness(pathFilename: str | PathLike[Any]) -> numpy.ndarray:
152
+ def analyzeSkewness(pathFilename: str | PathLike[Any]) -> float | None:
153
153
  return ffprobeShotgunAndCache(pathFilename).get('skewness')
154
154
 
155
155
  @registrationAudioAspect('Spectral kurtosis')
156
- def analyzeKurtosis(pathFilename: str | PathLike[Any]) -> numpy.ndarray:
156
+ def analyzeKurtosis(pathFilename: str | PathLike[Any]) -> float | None:
157
157
  return ffprobeShotgunAndCache(pathFilename).get('kurtosis')
158
158
 
159
159
  @registrationAudioAspect('Spectral entropy')
160
- def analyzeSpectralEntropy(pathFilename: str | PathLike[Any]) -> numpy.ndarray:
160
+ def analyzeSpectralEntropy(pathFilename: str | PathLike[Any]) -> float | None:
161
161
  return ffprobeShotgunAndCache(pathFilename).get('entropy')
162
162
 
163
163
  @registrationAudioAspect('Spectral flatness')
164
- def analyzeFlatness(pathFilename: str | PathLike[Any]) -> numpy.ndarray:
164
+ def analyzeFlatness(pathFilename: str | PathLike[Any]) -> float | None:
165
165
  return ffprobeShotgunAndCache(pathFilename).get('flatness')
166
166
 
167
167
  @registrationAudioAspect('Spectral crest')
168
- def analyzeCrest(pathFilename: str | PathLike[Any]) -> numpy.ndarray:
168
+ def analyzeCrest(pathFilename: str | PathLike[Any]) -> float | None:
169
169
  return ffprobeShotgunAndCache(pathFilename).get('crest')
170
170
 
171
171
  @registrationAudioAspect('Spectral flux')
172
- def analyzeFlux(pathFilename: str | PathLike[Any]) -> numpy.ndarray:
172
+ def analyzeFlux(pathFilename: str | PathLike[Any]) -> float | None:
173
173
  return ffprobeShotgunAndCache(pathFilename).get('flux')
174
174
 
175
175
  @registrationAudioAspect('Spectral slope')
176
- def analyzeSlope(pathFilename: str | PathLike[Any]) -> numpy.ndarray:
176
+ def analyzeSlope(pathFilename: str | PathLike[Any]) -> float | None:
177
177
  return ffprobeShotgunAndCache(pathFilename).get('slope')
178
178
 
179
179
  @registrationAudioAspect('Spectral decrease')
180
- def analyzeDecrease(pathFilename: str | PathLike[Any]) -> numpy.ndarray:
180
+ def analyzeDecrease(pathFilename: str | PathLike[Any]) -> float | None:
181
181
  return ffprobeShotgunAndCache(pathFilename).get('decrease')
182
182
 
183
183
  @registrationAudioAspect('Spectral rolloff')
184
- def analyzeRolloff(pathFilename: str | PathLike[Any]) -> numpy.ndarray:
184
+ def analyzeRolloff(pathFilename: str | PathLike[Any]) -> float | None:
185
185
  return ffprobeShotgunAndCache(pathFilename).get('rolloff')
186
186
 
187
187
  @registrationAudioAspect('Abs_Peak_count')
@@ -1,14 +1,12 @@
1
1
  from collections.abc import Callable, Sequence
2
2
  from concurrent.futures import ProcessPoolExecutor, as_completed
3
3
  from numpy.typing import NDArray
4
+ from os import PathLike
4
5
  from typing import Any, cast, ParamSpec, TypeAlias, TYPE_CHECKING, TypeVar
5
6
  from Z0Z_tools import defineConcurrencyLimit, oopsieKwargsie, stft
6
7
  import cachetools
7
8
  import inspect
8
- import librosa
9
- import multiprocessing
10
9
  import numpy
11
- from os import PathLike
12
10
  import pathlib
13
11
  import soundfile
14
12
  import torch
@@ -19,8 +17,11 @@ if TYPE_CHECKING:
19
17
  else:
20
18
  TypedDict = dict
21
19
 
22
- if __name__ == '__main__':
23
- multiprocessing.set_start_method('spawn')
20
+ from multiprocessing import set_start_method as multiprocessing_set_start_method
21
+ try:
22
+ multiprocessing_set_start_method('spawn')
23
+ except RuntimeError:
24
+ pass
24
25
 
25
26
  warnings.filterwarnings('ignore', category=UserWarning, module='torchmetrics', message='.*fast=True.*')
26
27
 
@@ -112,9 +113,9 @@ def analyzeAudioFile(pathFilename: str | PathLike[Any], listAspectNames: list[st
112
113
  else:
113
114
  raise ERRORmessage
114
115
 
115
- spectrogram = stft(waveform, sampleRate=sampleRate)
116
- spectrogramMagnitude = numpy.absolute(spectrogram)
117
- spectrogramPower = spectrogramMagnitude ** 2
116
+ # spectrogram = stft(waveform, sampleRate=sampleRate)
117
+ # spectrogramMagnitude = numpy.absolute(spectrogram)
118
+ # spectrogramPower = spectrogramMagnitude ** 2
118
119
 
119
120
  pytorchOnCPU = not torch.cuda.is_available() # False if GPU available, True if not
120
121
 
analyzeAudio/py.typed ADDED
File without changes
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: analyzeAudio
3
- Version: 0.0.14
3
+ Version: 0.0.15
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: CC-BY-NC-4.0
@@ -15,7 +15,6 @@ Classifier: Intended Audience :: End Users/Desktop
15
15
  Classifier: Intended Audience :: Science/Research
16
16
  Classifier: Intended Audience :: Information Technology
17
17
  Classifier: Intended Audience :: Other Audience
18
- Classifier: License :: Free for non-commercial use
19
18
  Classifier: Natural Language :: English
20
19
  Classifier: Operating System :: OS Independent
21
20
  Classifier: Programming Language :: Python
@@ -44,10 +43,11 @@ Requires-Dist: torchmetrics[audio]
44
43
  Requires-Dist: tqdm
45
44
  Requires-Dist: Z0Z_tools
46
45
  Provides-Extra: testing
46
+ Requires-Dist: pytest; extra == "testing"
47
47
  Requires-Dist: pytest-cov; extra == "testing"
48
48
  Requires-Dist: pytest-xdist; extra == "testing"
49
- Requires-Dist: pytest; extra == "testing"
50
49
  Requires-Dist: pyupgrade; extra == "testing"
50
+ Dynamic: license-file
51
51
 
52
52
  # analyzeAudio
53
53
 
@@ -139,12 +139,45 @@ print(audioAspects['Chromagram']['analyzerParameters'])
139
139
  'Signal entropy': float
140
140
  'Spectral Bandwidth': NDArray[float64] # shape(..., 1, frames)
141
141
  'Spectral Bandwidth mean': float
142
- 'Spectral centroid': NDArray[float64] # shape(channels, frames)
143
- 'Spectral centroid mean': float
144
142
  'Spectral Centroid': NDArray[float64] # shape(..., 1, frames)
145
143
  'Spectral Centroid mean': float
146
144
  'Spectral Contrast': NDArray[float64] # shape(..., 7, frames)
147
145
  'Spectral Contrast mean': float
146
+ 'Spectral Flatness': NDArray[float64] # shape(..., 1, frames)
147
+ 'Spectral Flatness mean': float
148
+ 'SRMR': NDArray[float64] # shape(...)
149
+ 'SRMR mean': float
150
+ 'Tempo': NDArray[float64] # shape(...)
151
+ 'Tempo mean': float
152
+ 'Tempogram': NDArray[float64] # shape(..., 384, samples)
153
+ 'Tempogram mean': float
154
+ 'Zero-crossing rate': NDArray[float64] # shape(..., 1, frames)
155
+ 'Zero-crossing rate mean': float
156
+ 'Zero-crossings rate': float
157
+ ```
158
+
159
+ ### I had to revert back to these
160
+
161
+ ```python
162
+ 'Spectral centroid': float
163
+ 'Spectral crest': float
164
+ 'Spectral decrease': float
165
+ 'Spectral entropy': float
166
+ 'Spectral flatness': float
167
+ 'Spectral flux': float
168
+ 'Spectral kurtosis': float
169
+ 'Spectral rolloff': float
170
+ 'Spectral skewness': float
171
+ 'Spectral slope': float
172
+ 'Spectral spread': float
173
+ 'Spectral variance': float
174
+ ```
175
+
176
+ ### Removed (temporarily, I hope)
177
+
178
+ ```python
179
+ 'Spectral centroid': NDArray[float64] # shape(channels, frames)
180
+ 'Spectral centroid mean': float
148
181
  'Spectral crest': NDArray[float64] # shape(channels, frames)
149
182
  'Spectral crest mean': float
150
183
  'Spectral decrease': NDArray[float64] # shape(channels, frames)
@@ -153,8 +186,6 @@ print(audioAspects['Chromagram']['analyzerParameters'])
153
186
  'Spectral entropy mean': float
154
187
  'Spectral flatness': NDArray[float64] # shape(channels, frames)
155
188
  'Spectral flatness mean': float
156
- 'Spectral Flatness': NDArray[float64] # shape(..., 1, frames)
157
- 'Spectral Flatness mean': float
158
189
  'Spectral flux': NDArray[float64] # shape(channels, frames)
159
190
  'Spectral flux mean': float
160
191
  'Spectral kurtosis': NDArray[float64] # shape(channels, frames)
@@ -169,15 +200,6 @@ print(audioAspects['Chromagram']['analyzerParameters'])
169
200
  'Spectral spread mean': float
170
201
  'Spectral variance': NDArray[float64] # shape(channels, frames)
171
202
  'Spectral variance mean': float
172
- 'SRMR': NDArray[float64] # shape(...)
173
- 'SRMR mean': float
174
- 'Tempo': NDArray[float64] # shape(...)
175
- 'Tempo mean': float
176
- 'Tempogram': NDArray[float64] # shape(..., 384, samples)
177
- 'Tempogram mean': float
178
- 'Zero-crossing rate': NDArray[float64] # shape(..., 1, frames)
179
- 'Zero-crossing rate mean': float
180
- 'Zero-crossings rate': float
181
203
  ```
182
204
 
183
205
  ## Installation
@@ -191,4 +213,4 @@ pip install analyzeAudio
191
213
  [![Static Badge](https://img.shields.io/badge/2011_August-Homeless_since-blue?style=flat)](https://HunterThinks.com/support)
192
214
  [![YouTube Channel Subscribers](https://img.shields.io/youtube/channel/subscribers/UC3Gx7kz61009NbhpRtPP7tw)](https://www.youtube.com/@HunterHogan)
193
215
 
194
- [![CC-BY-NC-4.0](https://github.com/hunterhogan/analyzeAudio/blob/main/CC-BY-NC-4.0.png)](https://creativecommons.org/licenses/by-nc/4.0/)
216
+ [![CC-BY-NC-4.0](https://github.com/hunterhogan/analyzeAudio/blob/main/CC-BY-NC-4.0.svg)](https://creativecommons.org/licenses/by-nc/4.0/)
@@ -1,16 +1,17 @@
1
1
  analyzeAudio/__init__.py,sha256=2D5JMeZfLGnwyQvt4Q2-HCsShHulcNXBM_Wu9vZPCiI,437
2
- analyzeAudio/analyzersUseFilename.py,sha256=iXF3Ut_Ldd6hKtNC54vpwRLGaQQA0UdE83aCMcFfVGI,10972
2
+ analyzeAudio/analyzersUseFilename.py,sha256=XMRmbARX7UzbTdPXOmQOQDDPennF2Vd1UaIIV8k6NrQ,10927
3
3
  analyzeAudio/analyzersUseSpectrogram.py,sha256=j-e69ICVHOC_W3ev8HOTem4KGGpE9QyKnYZEvFseMkE,1835
4
4
  analyzeAudio/analyzersUseTensor.py,sha256=-wD_QAd41lB65ceT5UedEoxWL078tZ0E-kC9ssDSghc,553
5
5
  analyzeAudio/analyzersUseWaveform.py,sha256=AwDyagz9bLLAq8ji4by51x7d2YWRdUQaY3iaw1k0yD4,1472
6
- analyzeAudio/audioAspectsRegistry.py,sha256=EvFKNncWKDv4KDyI0UcfBplkgVK_fGOFOdjolDy8hE0,8517
6
+ analyzeAudio/audioAspectsRegistry.py,sha256=p8GoVbmfGwZvj0YtSC3qbENaf-gKfAfUbNwpvC2R9V8,8571
7
+ analyzeAudio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
8
  analyzeAudio/pythonator.py,sha256=St6KmIxvHwoW6IuHcEJjjvUUrEkG0sPv2S3Th9rjJtE,5603
9
+ analyzeaudio-0.0.15.dist-info/licenses/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
8
10
  tests/conftest.py,sha256=BhZswOjkl_u-qiS4Zy38d2fETdWAtZiigeuXYBK8l0k,397
9
11
  tests/test_audioAspectsRegistry.py,sha256=-TWTLMdAn6IFv7ZdFWrBm1KxpLBa3Mz1sCygAwxV6gE,27
10
12
  tests/test_other.py,sha256=sd20ms4StQ13_3-gmwZwtAuoIAwfxWC5IXM_Cp5GQXM,428
11
- analyzeaudio-0.0.14.dist-info/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
12
- analyzeaudio-0.0.14.dist-info/METADATA,sha256=Q_oiZl_dpECEzAv33Zla9SuVugUKr0sw9IZuUxPGaZs,8659
13
- analyzeaudio-0.0.14.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
14
- analyzeaudio-0.0.14.dist-info/entry_points.txt,sha256=FHgSx7fndtZ6SnQ-nWVXf0NB59exaHQ2DtatTK9KrLg,100
15
- analyzeaudio-0.0.14.dist-info/top_level.txt,sha256=QV8LQ0r_1LIQuewxDcEzODpykv5qRYG3I70piOUSVRg,19
16
- analyzeaudio-0.0.14.dist-info/RECORD,,
13
+ analyzeaudio-0.0.15.dist-info/METADATA,sha256=EGGk2mw9BlVFMauAW9cjwo2uSUpxnNBw8CLcb9iA0sQ,9040
14
+ analyzeaudio-0.0.15.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
15
+ analyzeaudio-0.0.15.dist-info/entry_points.txt,sha256=FHgSx7fndtZ6SnQ-nWVXf0NB59exaHQ2DtatTK9KrLg,100
16
+ analyzeaudio-0.0.15.dist-info/top_level.txt,sha256=QV8LQ0r_1LIQuewxDcEzODpykv5qRYG3I70piOUSVRg,19
17
+ analyzeaudio-0.0.15.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.2)
2
+ Generator: setuptools (78.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5