Kudio 3.0.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.
- kudio-3.0.0/Kudio.egg-info/PKG-INFO +179 -0
- kudio-3.0.0/Kudio.egg-info/SOURCES.txt +49 -0
- kudio-3.0.0/Kudio.egg-info/dependency_links.txt +1 -0
- kudio-3.0.0/Kudio.egg-info/entry_points.txt +2 -0
- kudio-3.0.0/Kudio.egg-info/requires.txt +30 -0
- kudio-3.0.0/Kudio.egg-info/top_level.txt +1 -0
- kudio-3.0.0/LICENSE.txt +21 -0
- kudio-3.0.0/PKG-INFO +179 -0
- kudio-3.0.0/README.md +127 -0
- kudio-3.0.0/kudio/__init__.py +48 -0
- kudio-3.0.0/kudio/_deprecation.py +29 -0
- kudio-3.0.0/kudio/_version.py +4 -0
- kudio-3.0.0/kudio/cli.py +91 -0
- kudio-3.0.0/kudio/config.py +244 -0
- kudio-3.0.0/kudio/core/__init__.py +91 -0
- kudio-3.0.0/kudio/core/buffer.py +135 -0
- kudio-3.0.0/kudio/core/evaluator.py +263 -0
- kudio-3.0.0/kudio/core/feature.py +282 -0
- kudio-3.0.0/kudio/core/io.py +238 -0
- kudio-3.0.0/kudio/core/manager.py +176 -0
- kudio-3.0.0/kudio/core/stream.py +474 -0
- kudio-3.0.0/kudio/core/synth.py +256 -0
- kudio-3.0.0/kudio/effects/__init__.py +20 -0
- kudio-3.0.0/kudio/effects/augment.py +104 -0
- kudio-3.0.0/kudio/effects/silence.py +35 -0
- kudio-3.0.0/kudio/enhance/__init__.py +5 -0
- kudio-3.0.0/kudio/enhance/traditional.py +244 -0
- kudio-3.0.0/kudio/exceptions.py +55 -0
- kudio-3.0.0/kudio/py.typed +0 -0
- kudio-3.0.0/kudio/util/__init__.py +47 -0
- kudio-3.0.0/kudio/util/check.py +194 -0
- kudio-3.0.0/kudio/util/colors.py +145 -0
- kudio-3.0.0/kudio/util/conv.py +75 -0
- kudio-3.0.0/kudio/util/parallel.py +26 -0
- kudio-3.0.0/kudio/util/tools.py +65 -0
- kudio-3.0.0/kudio/util/visual.py +333 -0
- kudio-3.0.0/pyproject.toml +72 -0
- kudio-3.0.0/setup.cfg +4 -0
- kudio-3.0.0/tests/test_buffer.py +80 -0
- kudio-3.0.0/tests/test_cli.py +55 -0
- kudio-3.0.0/tests/test_config.py +52 -0
- kudio-3.0.0/tests/test_effects.py +81 -0
- kudio-3.0.0/tests/test_enhance.py +40 -0
- kudio-3.0.0/tests/test_evaluator.py +25 -0
- kudio-3.0.0/tests/test_feature.py +98 -0
- kudio-3.0.0/tests/test_io.py +84 -0
- kudio-3.0.0/tests/test_manager.py +48 -0
- kudio-3.0.0/tests/test_metrics.py +46 -0
- kudio-3.0.0/tests/test_package.py +76 -0
- kudio-3.0.0/tests/test_synth.py +67 -0
- kudio-3.0.0/tests/test_utils.py +42 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Kudio
|
|
3
|
+
Version: 3.0.0
|
|
4
|
+
Summary: Audio toolkit for industrial acoustic inspection: I/O, streaming, feature extraction, noisy-data synthesis, enhancement and evaluation.
|
|
5
|
+
Author-email: RL <recognizer.light@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/recklight/kudio
|
|
8
|
+
Project-URL: Repository, https://github.com/recklight/kudio
|
|
9
|
+
Project-URL: Issues, https://github.com/recklight/kudio/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/recklight/kudio/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: audio,acoustic,signal-processing,speech-enhancement
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE.txt
|
|
27
|
+
Requires-Dist: numpy<2.5,>=1.24
|
|
28
|
+
Requires-Dist: scipy>=1.10
|
|
29
|
+
Requires-Dist: librosa>=0.10
|
|
30
|
+
Requires-Dist: soundfile>=0.12
|
|
31
|
+
Requires-Dist: PyYAML>=6.0
|
|
32
|
+
Requires-Dist: tqdm>=4.60
|
|
33
|
+
Requires-Dist: PyWavelets>=1.4
|
|
34
|
+
Provides-Extra: audio
|
|
35
|
+
Requires-Dist: PyAudio>=0.2.13; extra == "audio"
|
|
36
|
+
Requires-Dist: sounddevice>=0.4.5; extra == "audio"
|
|
37
|
+
Provides-Extra: eval
|
|
38
|
+
Requires-Dist: mir_eval>=0.7; extra == "eval"
|
|
39
|
+
Requires-Dist: pystoi>=0.3.3; extra == "eval"
|
|
40
|
+
Requires-Dist: pysepm>=0.1; extra == "eval"
|
|
41
|
+
Provides-Extra: viz
|
|
42
|
+
Requires-Dist: matplotlib>=3.7; extra == "viz"
|
|
43
|
+
Provides-Extra: data
|
|
44
|
+
Requires-Dist: pandas>=2.0; extra == "data"
|
|
45
|
+
Requires-Dist: openpyxl>=3.1; extra == "data"
|
|
46
|
+
Provides-Extra: all
|
|
47
|
+
Requires-Dist: kudio[audio,data,eval,viz]; extra == "all"
|
|
48
|
+
Provides-Extra: dev
|
|
49
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
50
|
+
Requires-Dist: kudio[data]; extra == "dev"
|
|
51
|
+
Dynamic: license-file
|
|
52
|
+
|
|
53
|
+
# Kudio
|
|
54
|
+
|
|
55
|
+
[](https://pypi.org/project/kudio/)
|
|
56
|
+
[](https://pypi.org/project/kudio/)
|
|
57
|
+
[](LICENSE.txt)
|
|
58
|
+
|
|
59
|
+
**Lightweight, composable audio toolkit for acoustic inspection.**
|
|
60
|
+
|
|
61
|
+
Kudio gives you audio I/O, streaming/recording, feature extraction, noisy-data
|
|
62
|
+
synthesis, effects & augmentation, enhancement, and quality metrics — as small
|
|
63
|
+
composable functions with a clean, typed API.
|
|
64
|
+
|
|
65
|
+
The core stays light (numpy + soundfile + librosa); heavy or niche features
|
|
66
|
+
(plotting, dataframes, PESQ/STOI, live audio) are opt-in extras.
|
|
67
|
+
|
|
68
|
+
## Install
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install kudio # core: I/O, features, effects, synthesis, metrics
|
|
72
|
+
pip install kudio[audio] # + live capture / playback (PyAudio, sounddevice)
|
|
73
|
+
pip install kudio[eval] # + PESQ / STOI / SDR back-ends
|
|
74
|
+
pip install kudio[viz] # + plotting helpers (matplotlib)
|
|
75
|
+
pip install kudio[data] # + Excel / dataframe export (pandas, openpyxl)
|
|
76
|
+
pip install kudio[all] # everything
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Requires **Python 3.9+** (tested on CPython 3.9–3.13).
|
|
80
|
+
|
|
81
|
+
> The Python badge above reflects the version currently published on PyPI; it
|
|
82
|
+
> updates automatically once v3.0 is released.
|
|
83
|
+
|
|
84
|
+
## Quick start
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
import kudio
|
|
88
|
+
|
|
89
|
+
# --- I/O (soundfile-backed; float32) --------------------------------------
|
|
90
|
+
y, sr = kudio.file_load("clip.wav") # native rate, no resample
|
|
91
|
+
kudio.save_wave("out.wav", y, sr, subtype="PCM_24") # 16/24-bit or FLOAT
|
|
92
|
+
|
|
93
|
+
# --- features -------------------------------------------------------------
|
|
94
|
+
spec = kudio.waveform_to_spectrogram(y, norm=True) # log-power spectrogram
|
|
95
|
+
feat = kudio.mfcc(y, sr, n_mfcc=40) # (1, frames, 40)
|
|
96
|
+
mel = kudio.melspectrogram("clip.wav", n_mels=64)
|
|
97
|
+
|
|
98
|
+
# --- effects & augmentation ----------------------------------------------
|
|
99
|
+
clip, (a, b) = kudio.trim_silence(y, top_db=30) # isolate the event
|
|
100
|
+
segments = kudio.split_on_silence(y)
|
|
101
|
+
aug = kudio.pitch_shift(y, sr, n_steps=2)
|
|
102
|
+
aug = kudio.add_noise_snr(y, noise, snr_db=5, seed=0) # reproducible
|
|
103
|
+
spec = kudio.spec_augment(spec, freq_mask_width=8, time_mask_width=16, seed=0)
|
|
104
|
+
|
|
105
|
+
# --- noisy-data synthesis -------------------------------------------------
|
|
106
|
+
syx = kudio.Synthesizer("data/clean", "data/noise",
|
|
107
|
+
out_path="data/mixed", snr_ratio=(-5, 0, 5))
|
|
108
|
+
syx.syn(mode="inc", seed=17) # reproducible
|
|
109
|
+
|
|
110
|
+
# --- metrics (pure numpy, no extra deps) ----------------------------------
|
|
111
|
+
print(kudio.si_sdr(ref, est), kudio.snr(ref, est), kudio.segmental_snr(ref, est))
|
|
112
|
+
|
|
113
|
+
# --- recording (needs kudio[audio]) --------------------------------------
|
|
114
|
+
wave = kudio.record(seconds=3, sr=16000)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Command line
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
kudio devices # list audio devices
|
|
121
|
+
kudio info clip.wav # sr / channels / duration / peak
|
|
122
|
+
kudio convert in.wav out.wav --rate 16000 --subtype PCM_16
|
|
123
|
+
kudio synth --clean C --noise N --out O --snr -5 0 5 --seed 17
|
|
124
|
+
kudio trim in.wav out.wav --top-db 30
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Modules
|
|
128
|
+
|
|
129
|
+
| Module | What's inside |
|
|
130
|
+
|---|---|
|
|
131
|
+
| `kudio.core.io` | `file_load`, `save_wave`, `check_input`, `load_waves`, `copy_waves` |
|
|
132
|
+
| `kudio.core.feature` | `waveform_to_spectrogram`, `spectrogram_to_waveform`, `mfcc`, `melspectrogram`, ... |
|
|
133
|
+
| `kudio.effects` | `trim_silence`, `split_on_silence`, `time_stretch`, `pitch_shift`, `add_noise_snr`, `reverb`, `spec_augment` |
|
|
134
|
+
| `kudio.core.synth` | `Synthesizer` (SNR mixing, seedable) |
|
|
135
|
+
| `kudio.core.evaluator` | `si_sdr`, `snr`, `segmental_snr` (dep-free); `AudioEvaluate` (PESQ/STOI/SDR) |
|
|
136
|
+
| `kudio.core.stream` | `record`, `play_audio`, `Recorder`, `LocalStreamReader`, `RemoteStreamReader` |
|
|
137
|
+
| `kudio.util` | `CheckDevice`, `map_waves`, colored console helpers, timers |
|
|
138
|
+
|
|
139
|
+
Everything commonly used is importable straight from the top level (`kudio.…`).
|
|
140
|
+
|
|
141
|
+
## Errors
|
|
142
|
+
|
|
143
|
+
All library errors derive from `kudio.KudioError` (`AudioIOError`,
|
|
144
|
+
`FeatureError`, `DeviceError`, `SynthesisError`, `DependencyError`), so you can
|
|
145
|
+
catch them in one place. Missing an optional extra raises a `DependencyError`
|
|
146
|
+
that tells you exactly what to install.
|
|
147
|
+
|
|
148
|
+
## Logging
|
|
149
|
+
|
|
150
|
+
kudio uses the standard `logging` module (loggers named `kudio.*`) and prints
|
|
151
|
+
nothing by default:
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
import logging; logging.basicConfig(level=logging.INFO)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Migrating from v2
|
|
158
|
+
|
|
159
|
+
v3 is a cleanup release. The short cryptic names still work but now emit a
|
|
160
|
+
`DeprecationWarning` — switch to the canonical names:
|
|
161
|
+
|
|
162
|
+
| v2 (deprecated) | v3 canonical |
|
|
163
|
+
|---|---|
|
|
164
|
+
| `w2s`, `wavform2spec` | `waveform_to_spectrogram` |
|
|
165
|
+
| `spec2wavform` | `spectrogram_to_waveform` |
|
|
166
|
+
| `f2s`, `wav2spec` | `file_to_spectrogram` |
|
|
167
|
+
| `s2w`, `spec2wav` | `save_spectrogram_as_wave` |
|
|
168
|
+
| `w2mfcc`, `wav2mfcc` | `mfcc` |
|
|
169
|
+
| `concat_mfcc_` | `mfcc_from_files` |
|
|
170
|
+
| `concat_logspec_`, `contextual_LogSpectrogram` | `logspec_from_files` |
|
|
171
|
+
| `wav2mel` | `melspectrogram` |
|
|
172
|
+
|
|
173
|
+
Also: `matplotlib` / `pandas` / `openpyxl` are no longer installed by default
|
|
174
|
+
(use the `[viz]` / `[data]` extras), and the deprecated `_config` / `_enh` /
|
|
175
|
+
`version` compatibility shims were removed.
|
|
176
|
+
|
|
177
|
+
## License
|
|
178
|
+
|
|
179
|
+
MIT — see [LICENSE.txt](LICENSE.txt).
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
LICENSE.txt
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
Kudio.egg-info/PKG-INFO
|
|
5
|
+
Kudio.egg-info/SOURCES.txt
|
|
6
|
+
Kudio.egg-info/dependency_links.txt
|
|
7
|
+
Kudio.egg-info/entry_points.txt
|
|
8
|
+
Kudio.egg-info/requires.txt
|
|
9
|
+
Kudio.egg-info/top_level.txt
|
|
10
|
+
kudio/__init__.py
|
|
11
|
+
kudio/_deprecation.py
|
|
12
|
+
kudio/_version.py
|
|
13
|
+
kudio/cli.py
|
|
14
|
+
kudio/config.py
|
|
15
|
+
kudio/exceptions.py
|
|
16
|
+
kudio/py.typed
|
|
17
|
+
kudio/core/__init__.py
|
|
18
|
+
kudio/core/buffer.py
|
|
19
|
+
kudio/core/evaluator.py
|
|
20
|
+
kudio/core/feature.py
|
|
21
|
+
kudio/core/io.py
|
|
22
|
+
kudio/core/manager.py
|
|
23
|
+
kudio/core/stream.py
|
|
24
|
+
kudio/core/synth.py
|
|
25
|
+
kudio/effects/__init__.py
|
|
26
|
+
kudio/effects/augment.py
|
|
27
|
+
kudio/effects/silence.py
|
|
28
|
+
kudio/enhance/__init__.py
|
|
29
|
+
kudio/enhance/traditional.py
|
|
30
|
+
kudio/util/__init__.py
|
|
31
|
+
kudio/util/check.py
|
|
32
|
+
kudio/util/colors.py
|
|
33
|
+
kudio/util/conv.py
|
|
34
|
+
kudio/util/parallel.py
|
|
35
|
+
kudio/util/tools.py
|
|
36
|
+
kudio/util/visual.py
|
|
37
|
+
tests/test_buffer.py
|
|
38
|
+
tests/test_cli.py
|
|
39
|
+
tests/test_config.py
|
|
40
|
+
tests/test_effects.py
|
|
41
|
+
tests/test_enhance.py
|
|
42
|
+
tests/test_evaluator.py
|
|
43
|
+
tests/test_feature.py
|
|
44
|
+
tests/test_io.py
|
|
45
|
+
tests/test_manager.py
|
|
46
|
+
tests/test_metrics.py
|
|
47
|
+
tests/test_package.py
|
|
48
|
+
tests/test_synth.py
|
|
49
|
+
tests/test_utils.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
numpy<2.5,>=1.24
|
|
2
|
+
scipy>=1.10
|
|
3
|
+
librosa>=0.10
|
|
4
|
+
soundfile>=0.12
|
|
5
|
+
PyYAML>=6.0
|
|
6
|
+
tqdm>=4.60
|
|
7
|
+
PyWavelets>=1.4
|
|
8
|
+
|
|
9
|
+
[all]
|
|
10
|
+
kudio[audio,data,eval,viz]
|
|
11
|
+
|
|
12
|
+
[audio]
|
|
13
|
+
PyAudio>=0.2.13
|
|
14
|
+
sounddevice>=0.4.5
|
|
15
|
+
|
|
16
|
+
[data]
|
|
17
|
+
pandas>=2.0
|
|
18
|
+
openpyxl>=3.1
|
|
19
|
+
|
|
20
|
+
[dev]
|
|
21
|
+
pytest>=7.0
|
|
22
|
+
kudio[data]
|
|
23
|
+
|
|
24
|
+
[eval]
|
|
25
|
+
mir_eval>=0.7
|
|
26
|
+
pystoi>=0.3.3
|
|
27
|
+
pysepm>=0.1
|
|
28
|
+
|
|
29
|
+
[viz]
|
|
30
|
+
matplotlib>=3.7
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
kudio
|
kudio-3.0.0/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RL
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
kudio-3.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Kudio
|
|
3
|
+
Version: 3.0.0
|
|
4
|
+
Summary: Audio toolkit for industrial acoustic inspection: I/O, streaming, feature extraction, noisy-data synthesis, enhancement and evaluation.
|
|
5
|
+
Author-email: RL <recognizer.light@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/recklight/kudio
|
|
8
|
+
Project-URL: Repository, https://github.com/recklight/kudio
|
|
9
|
+
Project-URL: Issues, https://github.com/recklight/kudio/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/recklight/kudio/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: audio,acoustic,signal-processing,speech-enhancement
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE.txt
|
|
27
|
+
Requires-Dist: numpy<2.5,>=1.24
|
|
28
|
+
Requires-Dist: scipy>=1.10
|
|
29
|
+
Requires-Dist: librosa>=0.10
|
|
30
|
+
Requires-Dist: soundfile>=0.12
|
|
31
|
+
Requires-Dist: PyYAML>=6.0
|
|
32
|
+
Requires-Dist: tqdm>=4.60
|
|
33
|
+
Requires-Dist: PyWavelets>=1.4
|
|
34
|
+
Provides-Extra: audio
|
|
35
|
+
Requires-Dist: PyAudio>=0.2.13; extra == "audio"
|
|
36
|
+
Requires-Dist: sounddevice>=0.4.5; extra == "audio"
|
|
37
|
+
Provides-Extra: eval
|
|
38
|
+
Requires-Dist: mir_eval>=0.7; extra == "eval"
|
|
39
|
+
Requires-Dist: pystoi>=0.3.3; extra == "eval"
|
|
40
|
+
Requires-Dist: pysepm>=0.1; extra == "eval"
|
|
41
|
+
Provides-Extra: viz
|
|
42
|
+
Requires-Dist: matplotlib>=3.7; extra == "viz"
|
|
43
|
+
Provides-Extra: data
|
|
44
|
+
Requires-Dist: pandas>=2.0; extra == "data"
|
|
45
|
+
Requires-Dist: openpyxl>=3.1; extra == "data"
|
|
46
|
+
Provides-Extra: all
|
|
47
|
+
Requires-Dist: kudio[audio,data,eval,viz]; extra == "all"
|
|
48
|
+
Provides-Extra: dev
|
|
49
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
50
|
+
Requires-Dist: kudio[data]; extra == "dev"
|
|
51
|
+
Dynamic: license-file
|
|
52
|
+
|
|
53
|
+
# Kudio
|
|
54
|
+
|
|
55
|
+
[](https://pypi.org/project/kudio/)
|
|
56
|
+
[](https://pypi.org/project/kudio/)
|
|
57
|
+
[](LICENSE.txt)
|
|
58
|
+
|
|
59
|
+
**Lightweight, composable audio toolkit for acoustic inspection.**
|
|
60
|
+
|
|
61
|
+
Kudio gives you audio I/O, streaming/recording, feature extraction, noisy-data
|
|
62
|
+
synthesis, effects & augmentation, enhancement, and quality metrics — as small
|
|
63
|
+
composable functions with a clean, typed API.
|
|
64
|
+
|
|
65
|
+
The core stays light (numpy + soundfile + librosa); heavy or niche features
|
|
66
|
+
(plotting, dataframes, PESQ/STOI, live audio) are opt-in extras.
|
|
67
|
+
|
|
68
|
+
## Install
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install kudio # core: I/O, features, effects, synthesis, metrics
|
|
72
|
+
pip install kudio[audio] # + live capture / playback (PyAudio, sounddevice)
|
|
73
|
+
pip install kudio[eval] # + PESQ / STOI / SDR back-ends
|
|
74
|
+
pip install kudio[viz] # + plotting helpers (matplotlib)
|
|
75
|
+
pip install kudio[data] # + Excel / dataframe export (pandas, openpyxl)
|
|
76
|
+
pip install kudio[all] # everything
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Requires **Python 3.9+** (tested on CPython 3.9–3.13).
|
|
80
|
+
|
|
81
|
+
> The Python badge above reflects the version currently published on PyPI; it
|
|
82
|
+
> updates automatically once v3.0 is released.
|
|
83
|
+
|
|
84
|
+
## Quick start
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
import kudio
|
|
88
|
+
|
|
89
|
+
# --- I/O (soundfile-backed; float32) --------------------------------------
|
|
90
|
+
y, sr = kudio.file_load("clip.wav") # native rate, no resample
|
|
91
|
+
kudio.save_wave("out.wav", y, sr, subtype="PCM_24") # 16/24-bit or FLOAT
|
|
92
|
+
|
|
93
|
+
# --- features -------------------------------------------------------------
|
|
94
|
+
spec = kudio.waveform_to_spectrogram(y, norm=True) # log-power spectrogram
|
|
95
|
+
feat = kudio.mfcc(y, sr, n_mfcc=40) # (1, frames, 40)
|
|
96
|
+
mel = kudio.melspectrogram("clip.wav", n_mels=64)
|
|
97
|
+
|
|
98
|
+
# --- effects & augmentation ----------------------------------------------
|
|
99
|
+
clip, (a, b) = kudio.trim_silence(y, top_db=30) # isolate the event
|
|
100
|
+
segments = kudio.split_on_silence(y)
|
|
101
|
+
aug = kudio.pitch_shift(y, sr, n_steps=2)
|
|
102
|
+
aug = kudio.add_noise_snr(y, noise, snr_db=5, seed=0) # reproducible
|
|
103
|
+
spec = kudio.spec_augment(spec, freq_mask_width=8, time_mask_width=16, seed=0)
|
|
104
|
+
|
|
105
|
+
# --- noisy-data synthesis -------------------------------------------------
|
|
106
|
+
syx = kudio.Synthesizer("data/clean", "data/noise",
|
|
107
|
+
out_path="data/mixed", snr_ratio=(-5, 0, 5))
|
|
108
|
+
syx.syn(mode="inc", seed=17) # reproducible
|
|
109
|
+
|
|
110
|
+
# --- metrics (pure numpy, no extra deps) ----------------------------------
|
|
111
|
+
print(kudio.si_sdr(ref, est), kudio.snr(ref, est), kudio.segmental_snr(ref, est))
|
|
112
|
+
|
|
113
|
+
# --- recording (needs kudio[audio]) --------------------------------------
|
|
114
|
+
wave = kudio.record(seconds=3, sr=16000)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Command line
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
kudio devices # list audio devices
|
|
121
|
+
kudio info clip.wav # sr / channels / duration / peak
|
|
122
|
+
kudio convert in.wav out.wav --rate 16000 --subtype PCM_16
|
|
123
|
+
kudio synth --clean C --noise N --out O --snr -5 0 5 --seed 17
|
|
124
|
+
kudio trim in.wav out.wav --top-db 30
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Modules
|
|
128
|
+
|
|
129
|
+
| Module | What's inside |
|
|
130
|
+
|---|---|
|
|
131
|
+
| `kudio.core.io` | `file_load`, `save_wave`, `check_input`, `load_waves`, `copy_waves` |
|
|
132
|
+
| `kudio.core.feature` | `waveform_to_spectrogram`, `spectrogram_to_waveform`, `mfcc`, `melspectrogram`, ... |
|
|
133
|
+
| `kudio.effects` | `trim_silence`, `split_on_silence`, `time_stretch`, `pitch_shift`, `add_noise_snr`, `reverb`, `spec_augment` |
|
|
134
|
+
| `kudio.core.synth` | `Synthesizer` (SNR mixing, seedable) |
|
|
135
|
+
| `kudio.core.evaluator` | `si_sdr`, `snr`, `segmental_snr` (dep-free); `AudioEvaluate` (PESQ/STOI/SDR) |
|
|
136
|
+
| `kudio.core.stream` | `record`, `play_audio`, `Recorder`, `LocalStreamReader`, `RemoteStreamReader` |
|
|
137
|
+
| `kudio.util` | `CheckDevice`, `map_waves`, colored console helpers, timers |
|
|
138
|
+
|
|
139
|
+
Everything commonly used is importable straight from the top level (`kudio.…`).
|
|
140
|
+
|
|
141
|
+
## Errors
|
|
142
|
+
|
|
143
|
+
All library errors derive from `kudio.KudioError` (`AudioIOError`,
|
|
144
|
+
`FeatureError`, `DeviceError`, `SynthesisError`, `DependencyError`), so you can
|
|
145
|
+
catch them in one place. Missing an optional extra raises a `DependencyError`
|
|
146
|
+
that tells you exactly what to install.
|
|
147
|
+
|
|
148
|
+
## Logging
|
|
149
|
+
|
|
150
|
+
kudio uses the standard `logging` module (loggers named `kudio.*`) and prints
|
|
151
|
+
nothing by default:
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
import logging; logging.basicConfig(level=logging.INFO)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Migrating from v2
|
|
158
|
+
|
|
159
|
+
v3 is a cleanup release. The short cryptic names still work but now emit a
|
|
160
|
+
`DeprecationWarning` — switch to the canonical names:
|
|
161
|
+
|
|
162
|
+
| v2 (deprecated) | v3 canonical |
|
|
163
|
+
|---|---|
|
|
164
|
+
| `w2s`, `wavform2spec` | `waveform_to_spectrogram` |
|
|
165
|
+
| `spec2wavform` | `spectrogram_to_waveform` |
|
|
166
|
+
| `f2s`, `wav2spec` | `file_to_spectrogram` |
|
|
167
|
+
| `s2w`, `spec2wav` | `save_spectrogram_as_wave` |
|
|
168
|
+
| `w2mfcc`, `wav2mfcc` | `mfcc` |
|
|
169
|
+
| `concat_mfcc_` | `mfcc_from_files` |
|
|
170
|
+
| `concat_logspec_`, `contextual_LogSpectrogram` | `logspec_from_files` |
|
|
171
|
+
| `wav2mel` | `melspectrogram` |
|
|
172
|
+
|
|
173
|
+
Also: `matplotlib` / `pandas` / `openpyxl` are no longer installed by default
|
|
174
|
+
(use the `[viz]` / `[data]` extras), and the deprecated `_config` / `_enh` /
|
|
175
|
+
`version` compatibility shims were removed.
|
|
176
|
+
|
|
177
|
+
## License
|
|
178
|
+
|
|
179
|
+
MIT — see [LICENSE.txt](LICENSE.txt).
|
kudio-3.0.0/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Kudio
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/kudio/)
|
|
4
|
+
[](https://pypi.org/project/kudio/)
|
|
5
|
+
[](LICENSE.txt)
|
|
6
|
+
|
|
7
|
+
**Lightweight, composable audio toolkit for acoustic inspection.**
|
|
8
|
+
|
|
9
|
+
Kudio gives you audio I/O, streaming/recording, feature extraction, noisy-data
|
|
10
|
+
synthesis, effects & augmentation, enhancement, and quality metrics — as small
|
|
11
|
+
composable functions with a clean, typed API.
|
|
12
|
+
|
|
13
|
+
The core stays light (numpy + soundfile + librosa); heavy or niche features
|
|
14
|
+
(plotting, dataframes, PESQ/STOI, live audio) are opt-in extras.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install kudio # core: I/O, features, effects, synthesis, metrics
|
|
20
|
+
pip install kudio[audio] # + live capture / playback (PyAudio, sounddevice)
|
|
21
|
+
pip install kudio[eval] # + PESQ / STOI / SDR back-ends
|
|
22
|
+
pip install kudio[viz] # + plotting helpers (matplotlib)
|
|
23
|
+
pip install kudio[data] # + Excel / dataframe export (pandas, openpyxl)
|
|
24
|
+
pip install kudio[all] # everything
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Requires **Python 3.9+** (tested on CPython 3.9–3.13).
|
|
28
|
+
|
|
29
|
+
> The Python badge above reflects the version currently published on PyPI; it
|
|
30
|
+
> updates automatically once v3.0 is released.
|
|
31
|
+
|
|
32
|
+
## Quick start
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
import kudio
|
|
36
|
+
|
|
37
|
+
# --- I/O (soundfile-backed; float32) --------------------------------------
|
|
38
|
+
y, sr = kudio.file_load("clip.wav") # native rate, no resample
|
|
39
|
+
kudio.save_wave("out.wav", y, sr, subtype="PCM_24") # 16/24-bit or FLOAT
|
|
40
|
+
|
|
41
|
+
# --- features -------------------------------------------------------------
|
|
42
|
+
spec = kudio.waveform_to_spectrogram(y, norm=True) # log-power spectrogram
|
|
43
|
+
feat = kudio.mfcc(y, sr, n_mfcc=40) # (1, frames, 40)
|
|
44
|
+
mel = kudio.melspectrogram("clip.wav", n_mels=64)
|
|
45
|
+
|
|
46
|
+
# --- effects & augmentation ----------------------------------------------
|
|
47
|
+
clip, (a, b) = kudio.trim_silence(y, top_db=30) # isolate the event
|
|
48
|
+
segments = kudio.split_on_silence(y)
|
|
49
|
+
aug = kudio.pitch_shift(y, sr, n_steps=2)
|
|
50
|
+
aug = kudio.add_noise_snr(y, noise, snr_db=5, seed=0) # reproducible
|
|
51
|
+
spec = kudio.spec_augment(spec, freq_mask_width=8, time_mask_width=16, seed=0)
|
|
52
|
+
|
|
53
|
+
# --- noisy-data synthesis -------------------------------------------------
|
|
54
|
+
syx = kudio.Synthesizer("data/clean", "data/noise",
|
|
55
|
+
out_path="data/mixed", snr_ratio=(-5, 0, 5))
|
|
56
|
+
syx.syn(mode="inc", seed=17) # reproducible
|
|
57
|
+
|
|
58
|
+
# --- metrics (pure numpy, no extra deps) ----------------------------------
|
|
59
|
+
print(kudio.si_sdr(ref, est), kudio.snr(ref, est), kudio.segmental_snr(ref, est))
|
|
60
|
+
|
|
61
|
+
# --- recording (needs kudio[audio]) --------------------------------------
|
|
62
|
+
wave = kudio.record(seconds=3, sr=16000)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Command line
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
kudio devices # list audio devices
|
|
69
|
+
kudio info clip.wav # sr / channels / duration / peak
|
|
70
|
+
kudio convert in.wav out.wav --rate 16000 --subtype PCM_16
|
|
71
|
+
kudio synth --clean C --noise N --out O --snr -5 0 5 --seed 17
|
|
72
|
+
kudio trim in.wav out.wav --top-db 30
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Modules
|
|
76
|
+
|
|
77
|
+
| Module | What's inside |
|
|
78
|
+
|---|---|
|
|
79
|
+
| `kudio.core.io` | `file_load`, `save_wave`, `check_input`, `load_waves`, `copy_waves` |
|
|
80
|
+
| `kudio.core.feature` | `waveform_to_spectrogram`, `spectrogram_to_waveform`, `mfcc`, `melspectrogram`, ... |
|
|
81
|
+
| `kudio.effects` | `trim_silence`, `split_on_silence`, `time_stretch`, `pitch_shift`, `add_noise_snr`, `reverb`, `spec_augment` |
|
|
82
|
+
| `kudio.core.synth` | `Synthesizer` (SNR mixing, seedable) |
|
|
83
|
+
| `kudio.core.evaluator` | `si_sdr`, `snr`, `segmental_snr` (dep-free); `AudioEvaluate` (PESQ/STOI/SDR) |
|
|
84
|
+
| `kudio.core.stream` | `record`, `play_audio`, `Recorder`, `LocalStreamReader`, `RemoteStreamReader` |
|
|
85
|
+
| `kudio.util` | `CheckDevice`, `map_waves`, colored console helpers, timers |
|
|
86
|
+
|
|
87
|
+
Everything commonly used is importable straight from the top level (`kudio.…`).
|
|
88
|
+
|
|
89
|
+
## Errors
|
|
90
|
+
|
|
91
|
+
All library errors derive from `kudio.KudioError` (`AudioIOError`,
|
|
92
|
+
`FeatureError`, `DeviceError`, `SynthesisError`, `DependencyError`), so you can
|
|
93
|
+
catch them in one place. Missing an optional extra raises a `DependencyError`
|
|
94
|
+
that tells you exactly what to install.
|
|
95
|
+
|
|
96
|
+
## Logging
|
|
97
|
+
|
|
98
|
+
kudio uses the standard `logging` module (loggers named `kudio.*`) and prints
|
|
99
|
+
nothing by default:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
import logging; logging.basicConfig(level=logging.INFO)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Migrating from v2
|
|
106
|
+
|
|
107
|
+
v3 is a cleanup release. The short cryptic names still work but now emit a
|
|
108
|
+
`DeprecationWarning` — switch to the canonical names:
|
|
109
|
+
|
|
110
|
+
| v2 (deprecated) | v3 canonical |
|
|
111
|
+
|---|---|
|
|
112
|
+
| `w2s`, `wavform2spec` | `waveform_to_spectrogram` |
|
|
113
|
+
| `spec2wavform` | `spectrogram_to_waveform` |
|
|
114
|
+
| `f2s`, `wav2spec` | `file_to_spectrogram` |
|
|
115
|
+
| `s2w`, `spec2wav` | `save_spectrogram_as_wave` |
|
|
116
|
+
| `w2mfcc`, `wav2mfcc` | `mfcc` |
|
|
117
|
+
| `concat_mfcc_` | `mfcc_from_files` |
|
|
118
|
+
| `concat_logspec_`, `contextual_LogSpectrogram` | `logspec_from_files` |
|
|
119
|
+
| `wav2mel` | `melspectrogram` |
|
|
120
|
+
|
|
121
|
+
Also: `matplotlib` / `pandas` / `openpyxl` are no longer installed by default
|
|
122
|
+
(use the `[viz]` / `[data]` extras), and the deprecated `_config` / `_enh` /
|
|
123
|
+
`version` compatibility shims were removed.
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
MIT — see [LICENSE.txt](LICENSE.txt).
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""kudio — a lightweight, composable audio toolkit for acoustic inspection.
|
|
3
|
+
|
|
4
|
+
Audio I/O, streaming/recording, feature extraction, noisy-data synthesis,
|
|
5
|
+
effects/augmentation, enhancement, and evaluation metrics.
|
|
6
|
+
|
|
7
|
+
>>> import kudio
|
|
8
|
+
>>> y, sr = kudio.file_load('some.wav')
|
|
9
|
+
>>> spec = kudio.waveform_to_spectrogram(y)
|
|
10
|
+
>>> clean = kudio.trim_silence(y)[0]
|
|
11
|
+
|
|
12
|
+
Heavy/niche features are optional extras and are *not* imported here:
|
|
13
|
+
plotting (`kudio.util.visual`, needs ``kudio[viz]``), Excel export
|
|
14
|
+
(`kudio.util.conv`, needs ``kudio[data]``), and live audio
|
|
15
|
+
(`kudio[audio]`).
|
|
16
|
+
"""
|
|
17
|
+
import logging as _logging
|
|
18
|
+
|
|
19
|
+
from kudio._version import __author__, __version__
|
|
20
|
+
from kudio.config import KC, KudioConfig
|
|
21
|
+
from kudio.exceptions import (
|
|
22
|
+
AudioIOError,
|
|
23
|
+
DependencyError,
|
|
24
|
+
DeviceError,
|
|
25
|
+
FeatureError,
|
|
26
|
+
KudioError,
|
|
27
|
+
SynthesisError,
|
|
28
|
+
UnsupportedFormatError,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
from kudio import core, effects, enhance, util # noqa: E402
|
|
32
|
+
from kudio.core import * # noqa: F401,F403 (curated __all__)
|
|
33
|
+
from kudio.effects import * # noqa: F401,F403
|
|
34
|
+
from kudio.enhance import trad_enhance, wavelet_low_pass_filter
|
|
35
|
+
from kudio.util import * # noqa: F401,F403 (curated __all__)
|
|
36
|
+
|
|
37
|
+
_logging.getLogger(__name__).addHandler(_logging.NullHandler())
|
|
38
|
+
|
|
39
|
+
__all__ = [
|
|
40
|
+
'__version__', '__author__', 'KudioConfig', 'KC',
|
|
41
|
+
'trad_enhance', 'wavelet_low_pass_filter',
|
|
42
|
+
# exceptions
|
|
43
|
+
'KudioError', 'AudioIOError', 'UnsupportedFormatError', 'DeviceError',
|
|
44
|
+
'FeatureError', 'SynthesisError', 'DependencyError',
|
|
45
|
+
]
|
|
46
|
+
__all__ += core.__all__
|
|
47
|
+
__all__ += effects.__all__
|
|
48
|
+
__all__ += util.__all__
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Helpers for keeping backwards-compatible aliases while nudging callers
|
|
3
|
+
towards the v3 canonical names."""
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import functools
|
|
7
|
+
import warnings
|
|
8
|
+
from typing import Callable, Optional
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def alias(new: Callable, name: Optional[str] = None) -> Callable:
|
|
12
|
+
"""Return a wrapper around *new* that emits a ``DeprecationWarning``.
|
|
13
|
+
|
|
14
|
+
>>> w2s = alias(waveform_to_spectrogram, 'w2s')
|
|
15
|
+
"""
|
|
16
|
+
old_name = name or new.__name__
|
|
17
|
+
|
|
18
|
+
@functools.wraps(new)
|
|
19
|
+
def wrapper(*args, **kwargs):
|
|
20
|
+
warnings.warn(
|
|
21
|
+
f"kudio.{old_name}() is deprecated and will be removed in a future "
|
|
22
|
+
f"release; use kudio.{new.__name__}() instead.",
|
|
23
|
+
DeprecationWarning, stacklevel=2)
|
|
24
|
+
return new(*args, **kwargs)
|
|
25
|
+
|
|
26
|
+
wrapper.__name__ = old_name
|
|
27
|
+
wrapper.__qualname__ = old_name
|
|
28
|
+
wrapper.__doc__ = f"Deprecated alias for :func:`{new.__name__}`."
|
|
29
|
+
return wrapper
|