spafe-rs 0.1.1__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.
@@ -0,0 +1,268 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "autocfg"
7
+ version = "1.5.1"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
10
+
11
+ [[package]]
12
+ name = "heck"
13
+ version = "0.5.0"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
16
+
17
+ [[package]]
18
+ name = "libc"
19
+ version = "0.2.186"
20
+ source = "registry+https://github.com/rust-lang/crates.io-index"
21
+ checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
22
+
23
+ [[package]]
24
+ name = "matrixmultiply"
25
+ version = "0.3.10"
26
+ source = "registry+https://github.com/rust-lang/crates.io-index"
27
+ checksum = "a06de3016e9fae57a36fd14dba131fccf49f74b40b7fbdb472f96e361ec71a08"
28
+ dependencies = [
29
+ "autocfg",
30
+ "rawpointer",
31
+ ]
32
+
33
+ [[package]]
34
+ name = "ndarray"
35
+ version = "0.17.2"
36
+ source = "registry+https://github.com/rust-lang/crates.io-index"
37
+ checksum = "520080814a7a6b4a6e9070823bb24b4531daac8c4627e08ba5de8c5ef2f2752d"
38
+ dependencies = [
39
+ "matrixmultiply",
40
+ "num-complex",
41
+ "num-integer",
42
+ "num-traits",
43
+ "portable-atomic",
44
+ "portable-atomic-util",
45
+ "rawpointer",
46
+ ]
47
+
48
+ [[package]]
49
+ name = "num-complex"
50
+ version = "0.4.6"
51
+ source = "registry+https://github.com/rust-lang/crates.io-index"
52
+ checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
53
+ dependencies = [
54
+ "num-traits",
55
+ ]
56
+
57
+ [[package]]
58
+ name = "num-integer"
59
+ version = "0.1.46"
60
+ source = "registry+https://github.com/rust-lang/crates.io-index"
61
+ checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
62
+ dependencies = [
63
+ "num-traits",
64
+ ]
65
+
66
+ [[package]]
67
+ name = "num-traits"
68
+ version = "0.2.19"
69
+ source = "registry+https://github.com/rust-lang/crates.io-index"
70
+ checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
71
+ dependencies = [
72
+ "autocfg",
73
+ ]
74
+
75
+ [[package]]
76
+ name = "once_cell"
77
+ version = "1.21.4"
78
+ source = "registry+https://github.com/rust-lang/crates.io-index"
79
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
80
+
81
+ [[package]]
82
+ name = "portable-atomic"
83
+ version = "1.13.1"
84
+ source = "registry+https://github.com/rust-lang/crates.io-index"
85
+ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
86
+
87
+ [[package]]
88
+ name = "portable-atomic-util"
89
+ version = "0.2.7"
90
+ source = "registry+https://github.com/rust-lang/crates.io-index"
91
+ checksum = "c2a106d1259c23fac8e543272398ae0e3c0b8d33c88ed73d0cc71b0f1d902618"
92
+ dependencies = [
93
+ "portable-atomic",
94
+ ]
95
+
96
+ [[package]]
97
+ name = "primal-check"
98
+ version = "0.3.4"
99
+ source = "registry+https://github.com/rust-lang/crates.io-index"
100
+ checksum = "dc0d895b311e3af9902528fbb8f928688abbd95872819320517cc24ca6b2bd08"
101
+ dependencies = [
102
+ "num-integer",
103
+ ]
104
+
105
+ [[package]]
106
+ name = "proc-macro2"
107
+ version = "1.0.106"
108
+ source = "registry+https://github.com/rust-lang/crates.io-index"
109
+ checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
110
+ dependencies = [
111
+ "unicode-ident",
112
+ ]
113
+
114
+ [[package]]
115
+ name = "pyo3"
116
+ version = "0.29.0"
117
+ source = "registry+https://github.com/rust-lang/crates.io-index"
118
+ checksum = "cd274650b21d4bfc26a0a47587962c1edb425f69287324355cd040c3ea66071c"
119
+ dependencies = [
120
+ "libc",
121
+ "once_cell",
122
+ "portable-atomic",
123
+ "pyo3-build-config",
124
+ "pyo3-ffi",
125
+ "pyo3-macros",
126
+ ]
127
+
128
+ [[package]]
129
+ name = "pyo3-build-config"
130
+ version = "0.29.0"
131
+ source = "registry+https://github.com/rust-lang/crates.io-index"
132
+ checksum = "c5e2a7d2f0d013342f295c048ad19237add5154a55b1c5a254c0ec93d4109078"
133
+ dependencies = [
134
+ "target-lexicon",
135
+ ]
136
+
137
+ [[package]]
138
+ name = "pyo3-ffi"
139
+ version = "0.29.0"
140
+ source = "registry+https://github.com/rust-lang/crates.io-index"
141
+ checksum = "ca85c467da1bbc8d866eea5deff9cf29ea5f7785054a17da36e65bda9c05845b"
142
+ dependencies = [
143
+ "libc",
144
+ "pyo3-build-config",
145
+ ]
146
+
147
+ [[package]]
148
+ name = "pyo3-macros"
149
+ version = "0.29.0"
150
+ source = "registry+https://github.com/rust-lang/crates.io-index"
151
+ checksum = "9ac53762fd065daa3194dd09337a38bd793a188100fd1a9304c4ab312d901771"
152
+ dependencies = [
153
+ "proc-macro2",
154
+ "pyo3-macros-backend",
155
+ "quote",
156
+ "syn",
157
+ ]
158
+
159
+ [[package]]
160
+ name = "pyo3-macros-backend"
161
+ version = "0.29.0"
162
+ source = "registry+https://github.com/rust-lang/crates.io-index"
163
+ checksum = "4ca3a1557399783172dc5bf39cfca835157732532cba56b71d2292161e53b362"
164
+ dependencies = [
165
+ "heck",
166
+ "proc-macro2",
167
+ "quote",
168
+ "syn",
169
+ ]
170
+
171
+ [[package]]
172
+ name = "quote"
173
+ version = "1.0.45"
174
+ source = "registry+https://github.com/rust-lang/crates.io-index"
175
+ checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
176
+ dependencies = [
177
+ "proc-macro2",
178
+ ]
179
+
180
+ [[package]]
181
+ name = "rawpointer"
182
+ version = "0.2.1"
183
+ source = "registry+https://github.com/rust-lang/crates.io-index"
184
+ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
185
+
186
+ [[package]]
187
+ name = "rustfft"
188
+ version = "6.4.1"
189
+ source = "registry+https://github.com/rust-lang/crates.io-index"
190
+ checksum = "21db5f9893e91f41798c88680037dba611ca6674703c1a18601b01a72c8adb89"
191
+ dependencies = [
192
+ "num-complex",
193
+ "num-integer",
194
+ "num-traits",
195
+ "primal-check",
196
+ "strength_reduce",
197
+ "transpose",
198
+ ]
199
+
200
+ [[package]]
201
+ name = "spafe"
202
+ version = "0.1.1"
203
+ dependencies = [
204
+ "ndarray",
205
+ "num-complex",
206
+ "pyo3",
207
+ "rustfft",
208
+ "thiserror",
209
+ ]
210
+
211
+ [[package]]
212
+ name = "strength_reduce"
213
+ version = "0.2.4"
214
+ source = "registry+https://github.com/rust-lang/crates.io-index"
215
+ checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82"
216
+
217
+ [[package]]
218
+ name = "syn"
219
+ version = "2.0.118"
220
+ source = "registry+https://github.com/rust-lang/crates.io-index"
221
+ checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422"
222
+ dependencies = [
223
+ "proc-macro2",
224
+ "quote",
225
+ "unicode-ident",
226
+ ]
227
+
228
+ [[package]]
229
+ name = "target-lexicon"
230
+ version = "0.13.5"
231
+ source = "registry+https://github.com/rust-lang/crates.io-index"
232
+ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
233
+
234
+ [[package]]
235
+ name = "thiserror"
236
+ version = "2.0.18"
237
+ source = "registry+https://github.com/rust-lang/crates.io-index"
238
+ checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
239
+ dependencies = [
240
+ "thiserror-impl",
241
+ ]
242
+
243
+ [[package]]
244
+ name = "thiserror-impl"
245
+ version = "2.0.18"
246
+ source = "registry+https://github.com/rust-lang/crates.io-index"
247
+ checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"
248
+ dependencies = [
249
+ "proc-macro2",
250
+ "quote",
251
+ "syn",
252
+ ]
253
+
254
+ [[package]]
255
+ name = "transpose"
256
+ version = "0.2.3"
257
+ source = "registry+https://github.com/rust-lang/crates.io-index"
258
+ checksum = "1ad61aed86bc3faea4300c7aee358b4c6d0c8d6ccc36524c96e4c92ccf26e77e"
259
+ dependencies = [
260
+ "num-integer",
261
+ "strength_reduce",
262
+ ]
263
+
264
+ [[package]]
265
+ name = "unicode-ident"
266
+ version = "1.0.24"
267
+ source = "registry+https://github.com/rust-lang/crates.io-index"
268
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
@@ -0,0 +1,41 @@
1
+ [package]
2
+ name = "spafe"
3
+ version = "0.1.1"
4
+ edition = "2024"
5
+ description = "Rust port of the spafe audio feature extraction library and jenellefeather/chcochleagram"
6
+ authors = ["Yehor Smoliakov <egorsmkv@gmail.com>"]
7
+ license = "BSD-3-Clause"
8
+ repository = "https://github.com/RustedBytes/spafe"
9
+ homepage = "https://github.com/RustedBytes/spafe"
10
+ documentation = "https://docs.rs/spafe"
11
+ readme = "README.md"
12
+ keywords = ["audio", "speech", "features", "mfcc", "cochleagram"]
13
+ categories = ["multimedia::audio", "science"]
14
+ exclude = [
15
+ ".github/",
16
+ ".gitignore",
17
+ "examples/python/",
18
+ "notebooks/",
19
+ "py.typed",
20
+ "pyproject.toml",
21
+ "spafe.pyi",
22
+ "uv.lock",
23
+ ]
24
+
25
+ [lib]
26
+ crate-type = ["rlib", "cdylib"]
27
+
28
+ [dependencies]
29
+ ndarray = "0.17"
30
+ num-complex = "0.4"
31
+ pyo3 = { version = "0.29", optional = true }
32
+ rustfft = "6"
33
+ thiserror = "2"
34
+
35
+ [features]
36
+ default = []
37
+ # Enables Rust's portable SIMD API for hot numeric kernels. This currently
38
+ # requires a nightly compiler because `std::simd` is still feature-gated.
39
+ portable-simd = []
40
+ python = ["dep:pyo3"]
41
+ python-extension = ["python", "pyo3/extension-module"]
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Jenelle Feather
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.
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2019, Ayoub Malek
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,162 @@
1
+ Metadata-Version: 2.4
2
+ Name: spafe-rs
3
+ Version: 0.1.1
4
+ Classifier: Development Status :: 3 - Alpha
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: Intended Audience :: Science/Research
7
+ Classifier: License :: OSI Approved :: BSD License
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Rust
10
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
11
+ Classifier: Topic :: Scientific/Engineering
12
+ Requires-Dist: matplotlib>=3.8 ; extra == 'examples'
13
+ Requires-Dist: numpy>=2 ; extra == 'examples'
14
+ Provides-Extra: examples
15
+ License-File: LICENSE-CHCOCHLEGRAM
16
+ License-File: LICENSE-SPAFE
17
+ Summary: Rust port of the spafe audio feature extraction library and jenellefeather/chcochleagram
18
+ Keywords: audio,speech,features,mfcc,cochleagram
19
+ Home-Page: https://github.com/RustedBytes/spafe
20
+ Author-email: Yehor Smoliakov <egorsmkv@gmail.com>
21
+ License-Expression: BSD-3-Clause
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
24
+ Project-URL: Documentation, https://docs.rs/spafe
25
+ Project-URL: Homepage, https://github.com/RustedBytes/spafe
26
+ Project-URL: Repository, https://github.com/RustedBytes/spafe
27
+
28
+ # Spafe
29
+
30
+ Native Rust implementation of the core
31
+ [`spafe`](https://pypi.org/project/spafe/) audio feature extraction APIs and
32
+ [`jenellefeather/chcochleagram`](https://github.com/jenellefeather/chcochleagram)
33
+ cochleagram routines.
34
+
35
+ The crate provides filter banks, spectrograms, cepstral features, spectral
36
+ descriptors, frequency estimators, cochleagram generation, preprocessing helpers,
37
+ and deterministic SVG visualization helpers.
38
+
39
+ ## Build
40
+
41
+ ```bash
42
+ cargo build
43
+ ```
44
+
45
+ The crate also has an opt-in portable SIMD path for hot numeric kernels. Because
46
+ `std::simd` is still unstable, this feature currently requires nightly Rust:
47
+
48
+ ```bash
49
+ cargo +nightly build --features portable-simd
50
+ ```
51
+
52
+ ## Python Bindings
53
+
54
+ The crate exposes a PyO3 extension module through maturin. The Python package is
55
+ published as `spafe-rs` and imports as `spafe`. Python functions use plain
56
+ Python lists for one-dimensional signals and nested lists for matrices.
57
+
58
+ Install locally in a virtual environment:
59
+
60
+ ```bash
61
+ python -m pip install maturin
62
+ maturin develop
63
+ ```
64
+
65
+ Build a wheel:
66
+
67
+ ```bash
68
+ python -m pip install build
69
+ python -m build --wheel
70
+ ```
71
+
72
+ Basic Python usage:
73
+
74
+ ```python
75
+ import math
76
+ import spafe
77
+
78
+ fs = 16_000
79
+ sig = [math.sin(2.0 * math.pi * 440.0 * n / fs) for n in range(fs)]
80
+ opts = spafe.FeatureOptions(fs=fs, nfft=256, nfilts=24)
81
+
82
+ ceps = spafe.mfcc(sig, opts)
83
+ fbanks, centers = spafe.mel_filter_banks(spafe.FilterBankOptions(nfft=256))
84
+
85
+ print(len(ceps), len(ceps[0]))
86
+ print(len(fbanks), len(centers))
87
+ ```
88
+
89
+ ## Test
90
+
91
+ ```bash
92
+ cargo test --all-targets
93
+ cargo clippy --all-targets -- -D warnings
94
+ RUSTDOCFLAGS="-D warnings -D missing_docs" cargo doc --no-deps
95
+ ```
96
+
97
+ ## Examples
98
+
99
+ Generate a filter-bank SVG:
100
+
101
+ ```bash
102
+ cargo run --example fbanks
103
+ open target/fbanks.svg
104
+ ```
105
+
106
+ Generate a cochleagram SVG:
107
+
108
+ ```bash
109
+ cargo run --example cochleagram
110
+ open target/cochleagram.svg
111
+ ```
112
+
113
+ Python examples live in `examples/python`, use matplotlib, and write outputs to
114
+ `target/python-examples`:
115
+
116
+ ```bash
117
+ python -m pip install matplotlib
118
+ python examples/python/features.py
119
+ python examples/python/fbanks.py
120
+ python examples/python/pitch.py
121
+ python examples/python/cochleagram.py
122
+ ```
123
+
124
+ Interactive notebooks live in `notebooks`:
125
+
126
+ ```bash
127
+ python -m pip install notebook matplotlib numpy
128
+ jupyter notebook notebooks
129
+ ```
130
+
131
+ They cover feature extraction, filter banks, pitch tracking, cochleagrams,
132
+ spectrogram variants, conversion helpers, parameter sensitivity, option tuning,
133
+ performance, and visualization/export/classification recipes.
134
+ The real-audio notebook uses `notebooks/sample_uk.opus` and requires `ffmpeg`.
135
+
136
+ ## Basic Usage
137
+
138
+ ```rust
139
+ use spafe::prelude::*;
140
+
141
+ fn main() -> spafe::Result<()> {
142
+ let fs = 16_000;
143
+ let signal = vec![0.0; fs];
144
+ let opts = FeatureOptions {
145
+ fs,
146
+ ..Default::default()
147
+ };
148
+
149
+ let coeffs = mfcc(&signal, &opts)?;
150
+ println!("frames={}, coeffs={}", coeffs.nrows(), coeffs.ncols());
151
+
152
+ let coch = cochleagram(&signal, &CochleagramOptions {
153
+ signal_size: signal.len(),
154
+ sr: fs,
155
+ env_sr: 400,
156
+ ..Default::default()
157
+ })?;
158
+ println!("filters={}, samples={}", coch.cochleagram.nrows(), coch.cochleagram.ncols());
159
+ Ok(())
160
+ }
161
+ ```
162
+
@@ -0,0 +1,134 @@
1
+ # Spafe
2
+
3
+ Native Rust implementation of the core
4
+ [`spafe`](https://pypi.org/project/spafe/) audio feature extraction APIs and
5
+ [`jenellefeather/chcochleagram`](https://github.com/jenellefeather/chcochleagram)
6
+ cochleagram routines.
7
+
8
+ The crate provides filter banks, spectrograms, cepstral features, spectral
9
+ descriptors, frequency estimators, cochleagram generation, preprocessing helpers,
10
+ and deterministic SVG visualization helpers.
11
+
12
+ ## Build
13
+
14
+ ```bash
15
+ cargo build
16
+ ```
17
+
18
+ The crate also has an opt-in portable SIMD path for hot numeric kernels. Because
19
+ `std::simd` is still unstable, this feature currently requires nightly Rust:
20
+
21
+ ```bash
22
+ cargo +nightly build --features portable-simd
23
+ ```
24
+
25
+ ## Python Bindings
26
+
27
+ The crate exposes a PyO3 extension module through maturin. The Python package is
28
+ published as `spafe-rs` and imports as `spafe`. Python functions use plain
29
+ Python lists for one-dimensional signals and nested lists for matrices.
30
+
31
+ Install locally in a virtual environment:
32
+
33
+ ```bash
34
+ python -m pip install maturin
35
+ maturin develop
36
+ ```
37
+
38
+ Build a wheel:
39
+
40
+ ```bash
41
+ python -m pip install build
42
+ python -m build --wheel
43
+ ```
44
+
45
+ Basic Python usage:
46
+
47
+ ```python
48
+ import math
49
+ import spafe
50
+
51
+ fs = 16_000
52
+ sig = [math.sin(2.0 * math.pi * 440.0 * n / fs) for n in range(fs)]
53
+ opts = spafe.FeatureOptions(fs=fs, nfft=256, nfilts=24)
54
+
55
+ ceps = spafe.mfcc(sig, opts)
56
+ fbanks, centers = spafe.mel_filter_banks(spafe.FilterBankOptions(nfft=256))
57
+
58
+ print(len(ceps), len(ceps[0]))
59
+ print(len(fbanks), len(centers))
60
+ ```
61
+
62
+ ## Test
63
+
64
+ ```bash
65
+ cargo test --all-targets
66
+ cargo clippy --all-targets -- -D warnings
67
+ RUSTDOCFLAGS="-D warnings -D missing_docs" cargo doc --no-deps
68
+ ```
69
+
70
+ ## Examples
71
+
72
+ Generate a filter-bank SVG:
73
+
74
+ ```bash
75
+ cargo run --example fbanks
76
+ open target/fbanks.svg
77
+ ```
78
+
79
+ Generate a cochleagram SVG:
80
+
81
+ ```bash
82
+ cargo run --example cochleagram
83
+ open target/cochleagram.svg
84
+ ```
85
+
86
+ Python examples live in `examples/python`, use matplotlib, and write outputs to
87
+ `target/python-examples`:
88
+
89
+ ```bash
90
+ python -m pip install matplotlib
91
+ python examples/python/features.py
92
+ python examples/python/fbanks.py
93
+ python examples/python/pitch.py
94
+ python examples/python/cochleagram.py
95
+ ```
96
+
97
+ Interactive notebooks live in `notebooks`:
98
+
99
+ ```bash
100
+ python -m pip install notebook matplotlib numpy
101
+ jupyter notebook notebooks
102
+ ```
103
+
104
+ They cover feature extraction, filter banks, pitch tracking, cochleagrams,
105
+ spectrogram variants, conversion helpers, parameter sensitivity, option tuning,
106
+ performance, and visualization/export/classification recipes.
107
+ The real-audio notebook uses `notebooks/sample_uk.opus` and requires `ffmpeg`.
108
+
109
+ ## Basic Usage
110
+
111
+ ```rust
112
+ use spafe::prelude::*;
113
+
114
+ fn main() -> spafe::Result<()> {
115
+ let fs = 16_000;
116
+ let signal = vec![0.0; fs];
117
+ let opts = FeatureOptions {
118
+ fs,
119
+ ..Default::default()
120
+ };
121
+
122
+ let coeffs = mfcc(&signal, &opts)?;
123
+ println!("frames={}, coeffs={}", coeffs.nrows(), coeffs.ncols());
124
+
125
+ let coch = cochleagram(&signal, &CochleagramOptions {
126
+ signal_size: signal.len(),
127
+ sr: fs,
128
+ env_sr: 400,
129
+ ..Default::default()
130
+ })?;
131
+ println!("filters={}, samples={}", coch.cochleagram.nrows(), coch.cochleagram.ncols());
132
+ Ok(())
133
+ }
134
+ ```
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,45 @@
1
+ [build-system]
2
+ requires = ["maturin>=1.8,<2"]
3
+ build-backend = "maturin"
4
+
5
+ [project]
6
+ name = "spafe-rs"
7
+ version = "0.1.1"
8
+ description = "Rust port of the spafe audio feature extraction library and jenellefeather/chcochleagram"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "BSD-3-Clause"
12
+ authors = [
13
+ { name = "Yehor Smoliakov", email = "egorsmkv@gmail.com" },
14
+ ]
15
+ keywords = ["audio", "speech", "features", "mfcc", "cochleagram"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "Intended Audience :: Science/Research",
20
+ "License :: OSI Approved :: BSD License",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Rust",
23
+ "Topic :: Multimedia :: Sound/Audio :: Analysis",
24
+ "Topic :: Scientific/Engineering",
25
+ ]
26
+
27
+ [project.urls]
28
+ Homepage = "https://github.com/RustedBytes/spafe"
29
+ Repository = "https://github.com/RustedBytes/spafe"
30
+ Documentation = "https://docs.rs/spafe"
31
+
32
+ [project.optional-dependencies]
33
+ examples = ["matplotlib>=3.8", "numpy>=2"]
34
+
35
+ [tool.maturin]
36
+ features = ["python-extension"]
37
+ module-name = "spafe"
38
+ include = ["spafe.pyi", "py.typed"]
39
+ exclude = [
40
+ ".github/**/*",
41
+ ".gitignore",
42
+ "examples/**/*",
43
+ "notebooks/**/*",
44
+ "uv.lock",
45
+ ]