lfeats 0.1.2__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.
- lfeats-0.1.2/.gitignore +24 -0
- lfeats-0.1.2/LICENSE +21 -0
- lfeats-0.1.2/PKG-INFO +327 -0
- lfeats-0.1.2/README.md +278 -0
- lfeats-0.1.2/lfeats/__init__.py +18 -0
- lfeats-0.1.2/lfeats/cli.py +256 -0
- lfeats-0.1.2/lfeats/interfaces/__init__.py +4 -0
- lfeats-0.1.2/lfeats/interfaces/extractor.py +488 -0
- lfeats-0.1.2/lfeats/interfaces/resampler.py +93 -0
- lfeats-0.1.2/lfeats/interfaces/types.py +398 -0
- lfeats-0.1.2/lfeats/interfaces/utils.py +49 -0
- lfeats-0.1.2/lfeats/models/__init__.py +46 -0
- lfeats-0.1.2/lfeats/models/base.py +289 -0
- lfeats-0.1.2/lfeats/models/contentvec.py +147 -0
- lfeats-0.1.2/lfeats/models/data2vec.py +159 -0
- lfeats-0.1.2/lfeats/models/data2vec2.py +159 -0
- lfeats-0.1.2/lfeats/models/ecapa_tdnn.py +115 -0
- lfeats-0.1.2/lfeats/models/hubert.py +141 -0
- lfeats-0.1.2/lfeats/models/manager.py +47 -0
- lfeats-0.1.2/lfeats/models/next_tdnn.py +148 -0
- lfeats-0.1.2/lfeats/models/r_spin.py +135 -0
- lfeats-0.1.2/lfeats/models/r_vector.py +116 -0
- lfeats-0.1.2/lfeats/models/spidr.py +110 -0
- lfeats-0.1.2/lfeats/models/spin.py +196 -0
- lfeats-0.1.2/lfeats/models/sslzip.py +143 -0
- lfeats-0.1.2/lfeats/models/unispeech_sat.py +135 -0
- lfeats-0.1.2/lfeats/models/wav2vec2.py +167 -0
- lfeats-0.1.2/lfeats/models/wavlm.py +134 -0
- lfeats-0.1.2/lfeats/models/whisper.py +182 -0
- lfeats-0.1.2/lfeats/models/x_vector.py +115 -0
- lfeats-0.1.2/lfeats/resamplers/__init__.py +20 -0
- lfeats-0.1.2/lfeats/resamplers/base.py +76 -0
- lfeats-0.1.2/lfeats/resamplers/lilfilter.py +76 -0
- lfeats-0.1.2/lfeats/resamplers/manager.py +60 -0
- lfeats-0.1.2/lfeats/resamplers/soxr.py +90 -0
- lfeats-0.1.2/lfeats/resamplers/torchaudio.py +93 -0
- lfeats-0.1.2/lfeats/third_party/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/LICENSE +21 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/__init__.py +45 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/checkpoint_utils.py +937 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/config/__init__.py +4 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/config/config.yaml +20 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/data/__init__.py +11 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/data/dictionary.py +403 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/data/modality.py +14 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/data/text_compressor.py +58 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/dataclass/__init__.py +13 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/dataclass/configs.py +1147 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/dataclass/constants.py +56 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/dataclass/initialize.py +65 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/dataclass/utils.py +512 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/file_io.py +196 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/incremental_decoding_utils.py +51 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/logging/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/logging/meters.py +351 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/models/__init__.py +236 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/models/data2vec/__init__.py +7 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/models/data2vec/data2vec2.py +816 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/models/data2vec/data2vec_audio.py +539 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/models/data2vec/modalities/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/models/data2vec/modalities/audio.py +192 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/models/data2vec/modalities/base.py +684 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/models/data2vec/modalities/modules.py +590 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/models/fairseq_decoder.py +104 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/models/fairseq_encoder.py +92 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/models/fairseq_incremental_decoder.py +118 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/models/fairseq_model.py +579 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/models/hubert/__init__.py +7 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/models/hubert/hubert.py +578 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/models/wav2vec/__init__.py +10 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/models/wav2vec/utils.py +21 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/models/wav2vec/wav2vec2.py +1496 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/modules/__init__.py +106 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/modules/ema_module.py +215 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/modules/fairseq_dropout.py +51 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/modules/fp32_group_norm.py +25 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/modules/gelu.py +25 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/modules/gumbel_vector_quantizer.py +212 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/modules/layer_norm.py +48 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/modules/multihead_attention.py +910 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/modules/quant_noise.py +107 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/modules/same_pad.py +32 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/modules/transpose_last.py +21 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/quantization_utils.py +143 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/registry.py +104 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/tasks/__init__.py +138 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/tasks/audio_pretraining.py +253 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/tasks/fairseq_task.py +708 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/tasks/hubert_pretraining.py +191 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/tokenizer.py +15 -0
- lfeats-0.1.2/lfeats/third_party/fairseq/utils.py +951 -0
- lfeats-0.1.2/lfeats/third_party/next_tdnn_asv/LICENSE +201 -0
- lfeats-0.1.2/lfeats/third_party/next_tdnn_asv/SpeakerNet.py +227 -0
- lfeats-0.1.2/lfeats/third_party/next_tdnn_asv/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/next_tdnn_asv/aggregation/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/next_tdnn_asv/aggregation/vap_bn_tanh_fc_bn.py +49 -0
- lfeats-0.1.2/lfeats/third_party/next_tdnn_asv/configs/NeXt_TDNN_C256_B3_K65_7.py +27 -0
- lfeats-0.1.2/lfeats/third_party/next_tdnn_asv/configs/NeXt_TDNN_C256_B3_K65_7_cyclical_lr_step.py +27 -0
- lfeats-0.1.2/lfeats/third_party/next_tdnn_asv/configs/NeXt_TDNN_light_C256_B3_K65.py +27 -0
- lfeats-0.1.2/lfeats/third_party/next_tdnn_asv/configs/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/next_tdnn_asv/main.py +36 -0
- lfeats-0.1.2/lfeats/third_party/next_tdnn_asv/models/NeXt_TDNN.py +90 -0
- lfeats-0.1.2/lfeats/third_party/next_tdnn_asv/models/TSConvNeXt.py +80 -0
- lfeats-0.1.2/lfeats/third_party/next_tdnn_asv/models/TSConvNeXt_light.py +56 -0
- lfeats-0.1.2/lfeats/third_party/next_tdnn_asv/models/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/next_tdnn_asv/models/utils.py +43 -0
- lfeats-0.1.2/lfeats/third_party/next_tdnn_asv/preprocessing/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/next_tdnn_asv/preprocessing/mel_transform.py +69 -0
- lfeats-0.1.2/lfeats/third_party/rspin/LICENSE +21 -0
- lfeats-0.1.2/lfeats/third_party/rspin/__init__.py +1 -0
- lfeats-0.1.2/lfeats/third_party/rspin/model.py +64 -0
- lfeats-0.1.2/lfeats/third_party/rspin/wavlm_config.py +37 -0
- lfeats-0.1.2/lfeats/third_party/s3prl/LICENSE +201 -0
- lfeats-0.1.2/lfeats/third_party/s3prl/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/s3prl/upstream/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/s3prl/upstream/hubert/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/s3prl/upstream/hubert/convert.py +72 -0
- lfeats-0.1.2/lfeats/third_party/s3prl/upstream/hubert/hubert_model.py +609 -0
- lfeats-0.1.2/lfeats/third_party/s3prl/upstream/utils.py +63 -0
- lfeats-0.1.2/lfeats/third_party/s3prl/upstream/wav2vec2/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/s3prl/upstream/wav2vec2/wav2vec2_model.py +3386 -0
- lfeats-0.1.2/lfeats/third_party/s3prl/upstream/wavlm/WavLM.py +824 -0
- lfeats-0.1.2/lfeats/third_party/s3prl/upstream/wavlm/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/s3prl/upstream/wavlm/modules.py +846 -0
- lfeats-0.1.2/lfeats/third_party/s3prl/util/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/s3prl/util/download.py +211 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/LICENSE +201 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/dataio/__init__.py +5 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/dataio/dataio.py +1417 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/dataio/encoder.py +1216 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/dataio/preprocess.py +82 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/inference/__init__.py +17 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/inference/classifiers.py +322 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/inference/interfaces.py +694 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/lobes/__init__.py +9 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/lobes/features.py +862 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/lobes/models/ECAPA_TDNN.py +636 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/lobes/models/ResNet.py +520 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/lobes/models/Xvector.py +247 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/lobes/models/__init__.py +1 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/nnet/CNN.py +1571 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/nnet/containers.py +408 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/nnet/linear.py +91 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/nnet/normalization.py +668 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/nnet/pooling.py +609 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/processing/__init__.py +1 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/processing/features.py +1913 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/utils/__init__.py +7 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/utils/_workarounds.py +36 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/utils/autocast.py +252 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/utils/checkpoints.py +1384 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/utils/distributed.py +501 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/utils/fetching.py +436 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/utils/filter_analysis.py +226 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/utils/logger.py +321 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/utils/parameter_transfer.py +350 -0
- lfeats-0.1.2/lfeats/third_party/speechbrain/utils/run_opts.py +363 -0
- lfeats-0.1.2/lfeats/third_party/spin/LICENSE +21 -0
- lfeats-0.1.2/lfeats/third_party/spin/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/spin/model/__init__.py +1 -0
- lfeats-0.1.2/lfeats/third_party/spin/model/base.py +28 -0
- lfeats-0.1.2/lfeats/third_party/spin/model/spin.py +349 -0
- lfeats-0.1.2/lfeats/third_party/spin/nn/__init__.py +4 -0
- lfeats-0.1.2/lfeats/third_party/spin/nn/dnn.py +39 -0
- lfeats-0.1.2/lfeats/third_party/spin/nn/hubert.py +270 -0
- lfeats-0.1.2/lfeats/third_party/spin/nn/swav_vq_dis.py +202 -0
- lfeats-0.1.2/lfeats/third_party/spin/nn/wavlm.py +214 -0
- lfeats-0.1.2/lfeats/third_party/spin/util/__init__.py +18 -0
- lfeats-0.1.2/lfeats/third_party/spin/util/model_utils.py +55 -0
- lfeats-0.1.2/lfeats/third_party/spin/util/padding.py +37 -0
- lfeats-0.1.2/lfeats/third_party/timm/LICENSE +201 -0
- lfeats-0.1.2/lfeats/third_party/timm/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/timm/layers/__init__.py +0 -0
- lfeats-0.1.2/lfeats/third_party/timm/layers/drop.py +231 -0
- lfeats-0.1.2/lfeats/third_party/timm/layers/helpers.py +79 -0
- lfeats-0.1.2/lfeats/third_party/timm/layers/mlp.py +290 -0
- lfeats-0.1.2/lfeats/utils/__init__.py +4 -0
- lfeats-0.1.2/lfeats/utils/io.py +132 -0
- lfeats-0.1.2/lfeats/utils/paths.py +24 -0
- lfeats-0.1.2/lfeats/utils/validation.py +45 -0
- lfeats-0.1.2/lfeats/version.py +6 -0
- lfeats-0.1.2/pyproject.toml +94 -0
lfeats-0.1.2/.gitignore
ADDED
lfeats-0.1.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Takenori Yoshimura
|
|
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.
|
lfeats-0.1.2/PKG-INFO
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lfeats
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: A unified interface to extract hidden representations from speech foundation models
|
|
5
|
+
Project-URL: Documentation, https://takenori-y.github.io/lfeats/latest/
|
|
6
|
+
Project-URL: Source, https://github.com/takenori-y/lfeats
|
|
7
|
+
Author: Takenori Yoshimura
|
|
8
|
+
Maintainer-email: Takenori Yoshimura <takenori@sp.nitech.ac.jp>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: pytorch
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: huggingface-hub>=0.23.0
|
|
22
|
+
Requires-Dist: hydra-core>=1.3.0
|
|
23
|
+
Requires-Dist: hyperpyyaml>=0.0.1
|
|
24
|
+
Requires-Dist: lilfilter>=0.0.1
|
|
25
|
+
Requires-Dist: numpy>=1.23.0
|
|
26
|
+
Requires-Dist: onnxruntime>=1.19.0
|
|
27
|
+
Requires-Dist: parfive>=2.1.0
|
|
28
|
+
Requires-Dist: platformdirs>=2.0.0
|
|
29
|
+
Requires-Dist: requests>=2.27.0
|
|
30
|
+
Requires-Dist: soundfile>=0.10.2
|
|
31
|
+
Requires-Dist: soxr>=0.4.0
|
|
32
|
+
Requires-Dist: torch>=2.6.0
|
|
33
|
+
Requires-Dist: torchaudio>=2.6.0
|
|
34
|
+
Requires-Dist: transformers>=4.30.0
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: build; extra == 'dev'
|
|
37
|
+
Requires-Dist: matplotlib; extra == 'dev'
|
|
38
|
+
Requires-Dist: mdformat; extra == 'dev'
|
|
39
|
+
Requires-Dist: numpydoc; extra == 'dev'
|
|
40
|
+
Requires-Dist: pkginfo; extra == 'dev'
|
|
41
|
+
Requires-Dist: pydata-sphinx-theme; extra == 'dev'
|
|
42
|
+
Requires-Dist: pyright; extra == 'dev'
|
|
43
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
44
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
45
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
46
|
+
Requires-Dist: sphinx; extra == 'dev'
|
|
47
|
+
Requires-Dist: twine; extra == 'dev'
|
|
48
|
+
Description-Content-Type: text/markdown
|
|
49
|
+
|
|
50
|
+
# lfeats
|
|
51
|
+
|
|
52
|
+
*lfeats* provides a unified interface to extract hidden representations from various speech foundation models such as HuBERT and Whisper.
|
|
53
|
+
While these extracted features are task-independent, the package is primarily designed for speech generation tasks including text-to-speech and voice conversion.
|
|
54
|
+
|
|
55
|
+
[](https://github.com/astral-sh/ruff)
|
|
56
|
+
|
|
57
|
+
## Requirements
|
|
58
|
+
|
|
59
|
+
- Python 3.10+
|
|
60
|
+
- PyTorch 2.6.0+
|
|
61
|
+
|
|
62
|
+
## Documentation
|
|
63
|
+
|
|
64
|
+
- [**Reference Manual**](https://takenori-y.github.io/lfeats/0.1.2/)
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
The latest stable release can be installed via PyPI:
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
pip install lfeats
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Alternatively, the development version can be installed directly from the GitHub repository:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
pip install git+https://github.com/takenori-y/lfeats.git@master
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Supported Models
|
|
81
|
+
|
|
82
|
+
### Frame-Level Features
|
|
83
|
+
|
|
84
|
+
| Model Name | Model Variant | Layers | Dimension | Paper | Source | Model Hub |
|
|
85
|
+
| :--- | :--- | ---: | ---: | :---: | :---: | :---: |
|
|
86
|
+
| `contentvec` | `hubert-100` | 12 | 768 | [arXiv](https://arxiv.org/abs/2204.09224) | [GitHub](https://github.com/auspicious3000/contentvec) | |
|
|
87
|
+
| | `hubert-500` | 12 | 768 | | | |
|
|
88
|
+
| `data2vec` | `base` | 12 | 768 | [arXiv](https://arxiv.org/abs/2202.03555) | [GitHub](https://github.com/facebookresearch/fairseq/tree/main/examples/data2vec) | |
|
|
89
|
+
| | `large` | 24 | 1024 | | | |
|
|
90
|
+
| `data2vec2` | `base` | 8 | 768 | [arXiv](https://arxiv.org/abs/2212.07525) | [GitHub](https://github.com/facebookresearch/fairseq/tree/main/examples/data2vec) | |
|
|
91
|
+
| | `large` | 16 | 1024 | | | |
|
|
92
|
+
| `hubert` | `base` | 12 | 768 | [arXiv](https://arxiv.org/abs/2106.07447) | [GitHub](https://github.com/facebookresearch/fairseq/tree/main/examples/hubert) | [🤗](https://huggingface.co/facebook/hubert-base-ls960) |
|
|
93
|
+
| | `large` | 24 | 1024 | | | [🤗](https://huggingface.co/facebook/hubert-large-ll60k) |
|
|
94
|
+
| | `xlarge` | 48 | 1280 | | | [🤗](https://huggingface.co/facebook/hubert-xlarge-ll60k) |
|
|
95
|
+
| `r-spin` | `wavlm-32` | 12 | 768 | [arXiv](https://arxiv.org/abs/2311.09117) | [GitHub](https://github.com/vectominist/rspin) | |
|
|
96
|
+
| | `wavlm-64` | 12 | 768 | | | |
|
|
97
|
+
| | `wavlm-128` | 12 | 768 | | | |
|
|
98
|
+
| | `wavlm-256` | 12 | 768 | | | |
|
|
99
|
+
| | `wavlm-512` | 12 | 768 | | | |
|
|
100
|
+
| | `wavlm-1024` | 12 | 768 | | | |
|
|
101
|
+
| | `wavlm-2048` | 12 | 768 | | | |
|
|
102
|
+
| `spidr` | `base` | 12 | 768 | [arXiv](https://arxiv.org/abs/2512.20308) | [GitHub](https://github.com/facebookresearch/spidr) | |
|
|
103
|
+
| `spin` | `hubert-128` | 12 | 768 | [arXiv](https://arxiv.org/abs/2305.11072) | [GitHub](https://github.com/vectominist/spin) | |
|
|
104
|
+
| | `hubert-256` | 12 | 768 | | | |
|
|
105
|
+
| | `hubert-512` | 12 | 768 | | | |
|
|
106
|
+
| | `hubert-1024` | 12 | 768 | | | |
|
|
107
|
+
| | `hubert-2048` | 12 | 768 | | | |
|
|
108
|
+
| | `wavlm-128` | 12 | 768 | | | |
|
|
109
|
+
| | `wavlm-256` | 12 | 768 | | | |
|
|
110
|
+
| | `wavlm-512` | 12 | 768 | | | |
|
|
111
|
+
| | `wavlm-1024` | 12 | 768 | | | |
|
|
112
|
+
| | `wavlm-2048` | 12 | 768 | | | |
|
|
113
|
+
| `sslzip` | `tiny` | 0 | 16 | [ISCA](https://www.isca-archive.org/ssw_2025/yoshimura25_ssw.html) | [GitHub](https://github.com/sp-nitech/SSLZip) | [🤗](https://huggingface.co/takenori-y/SSLZip-16) |
|
|
114
|
+
| | `base` | 0 | 256 | | | [🤗](https://huggingface.co/takenori-y/SSLZip-256) |
|
|
115
|
+
| `unispeech-sat` | `base` | 12 | 768 | [arXiv](https://arxiv.org/abs/2110.05752) | [GitHub](https://github.com/microsoft/UniSpeech) | [🤗](https://huggingface.co/microsoft/unispeech-sat-base) |
|
|
116
|
+
| | `base-plus` | 12 | 768 | | | [🤗](https://huggingface.co/microsoft/unispeech-sat-base-plus) |
|
|
117
|
+
| | `large` | 24 | 1024 | | | [🤗](https://huggingface.co/microsoft/unispeech-sat-large) |
|
|
118
|
+
| `wav2vec2` | `base` | 12 | 768 | [arXiv](https://arxiv.org/abs/2006.11477) | [GitHub](https://github.com/facebookresearch/fairseq/tree/main/examples/wav2vec) | |
|
|
119
|
+
| | `large` | 24 | 1024 | | | |
|
|
120
|
+
| | `xlsr` | 24 | 1024 | [arXiv](https://arxiv.org/abs/2006.13979) | | |
|
|
121
|
+
| | `xlsr-v2` | 24 | 1024 | [arXiv](https://arxiv.org/abs/2111.09296) | [GitHub](https://github.com/facebookresearch/fairseq/tree/main/examples/wav2vec/xlsr) | |
|
|
122
|
+
| `wavlm` | `base` | 12 | 768 | [arXiv](https://arxiv.org/abs/2110.13900) | [GitHub](https://github.com/microsoft/unilm/tree/master/wavlm) | [🤗](https://huggingface.co/microsoft/wavlm-base) |
|
|
123
|
+
| | `base-plus` | 12 | 768 | | | [🤗](https://huggingface.co/microsoft/wavlm-base-plus) |
|
|
124
|
+
| | `large` | 24 | 1024 | | | [🤗](https://huggingface.co/microsoft/wavlm-large) |
|
|
125
|
+
| `whisper` | `tiny` | 4 | 384 | [arXiv](https://arxiv.org/abs/2212.04356) | [GitHub](https://github.com/openai/whisper) | [🤗](https://huggingface.co/openai/whisper-tiny) |
|
|
126
|
+
| | `base` | 6 | 512 | | | [🤗](https://huggingface.co/openai/whisper-base) |
|
|
127
|
+
| | `small` | 12 | 768 | | | [🤗](https://huggingface.co/openai/whisper-small) |
|
|
128
|
+
| | `medium` | 24 | 1024 | | | [🤗](https://huggingface.co/openai/whisper-medium) |
|
|
129
|
+
| | `large` | 32 | 1280 | | | [🤗](https://huggingface.co/openai/whisper-large) |
|
|
130
|
+
| | `large-v2` | 32 | 1280 | | | [🤗](https://huggingface.co/openai/whisper-large-v2) |
|
|
131
|
+
| | `large-v3` | 32 | 1280 | | | [🤗](https://huggingface.co/openai/whisper-large-v3) |
|
|
132
|
+
|
|
133
|
+
### Utterance-Level Features
|
|
134
|
+
|
|
135
|
+
| Model Name | Model Variant | Layers | Dimension | Paper | Source | Model Hub |
|
|
136
|
+
| :--- | :--- | ---: | ---: | :---: | :---: | :---: |
|
|
137
|
+
| `ecapa-tdnn` | `base` | 0 | 192 | [arXiv](https://arxiv.org/abs/2005.07143) | [GitHub](https://github.com/speechbrain/speechbrain) | [🤗](https://huggingface.co/speechbrain/spkrec-ecapa-voxceleb) |
|
|
138
|
+
| `next-tdnn` | `light` | 0 | 192 | [arXiv](https://arxiv.org/abs/2312.08603) | [GitHub](https://github.com/dmlguq456/NeXt_TDNN_ASV) | |
|
|
139
|
+
| | `base` | 0 | 192 | | | |
|
|
140
|
+
| | `base-v2` | 0 | 192 | | | |
|
|
141
|
+
| `r-vector` | `base` | 0 | 256 | [arXiv](https://arxiv.org/pdf/1910.12592) | [GitHub](https://github.com/speechbrain/speechbrain) | [🤗](https://huggingface.co/speechbrain/spkrec-resnet-voxceleb) |
|
|
142
|
+
| `x-vector` | `base` | 0 | 512 | [IEEE](https://ieeexplore.ieee.org/document/8461375) | [GitHub](https://github.com/speechbrain/speechbrain) | [🤗](https://huggingface.co/speechbrain/spkrec-xvect-voxceleb) |
|
|
143
|
+
|
|
144
|
+
> [!IMPORTANT]
|
|
145
|
+
> Users must comply with the respective licenses of the models.
|
|
146
|
+
> Please refer to the original repositories for detailed licensing information.
|
|
147
|
+
|
|
148
|
+
## Supported Resamplers
|
|
149
|
+
|
|
150
|
+
| Resampler Type | Quality Preset | Source | License |
|
|
151
|
+
| :--- | :--- | :---: | :--- |
|
|
152
|
+
| `lilfilter` | `base` | [GitHub](https://github.com/danpovey/filtering) | MIT |
|
|
153
|
+
| `soxr` | `quick` | [GitHub](https://github.com/dofuuz/python-soxr) | LGPL v2.1+ |
|
|
154
|
+
| | `low` | | |
|
|
155
|
+
| | `medium` | | |
|
|
156
|
+
| | `high` | | |
|
|
157
|
+
| | `very-high` | | |
|
|
158
|
+
| `torchaudio` | `kaiser-fast` | [GitHub](https://github.com/pytorch/audio) | BSD 2-Clause |
|
|
159
|
+
| | `kaiser-best` | | |
|
|
160
|
+
|
|
161
|
+
## Examples
|
|
162
|
+
|
|
163
|
+
### Simple Usage
|
|
164
|
+
|
|
165
|
+
`lfeats` simplifies the process of extracting hidden states from various speech foundation models.
|
|
166
|
+
You don't need to worry about differences between model types or input/output data types.
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
import lfeats
|
|
170
|
+
import numpy as np
|
|
171
|
+
|
|
172
|
+
# Prepare an audio waveform without zero-mean and unit-variance normalization.
|
|
173
|
+
# Either a NumPy array or a Torch tensor are accepted as the input of the extractor.
|
|
174
|
+
sample_rate = 16000
|
|
175
|
+
waveform = np.random.uniform(-1, 1, sample_rate)
|
|
176
|
+
|
|
177
|
+
# Initialize the extractor.
|
|
178
|
+
extractor = lfeats.Extractor(
|
|
179
|
+
model_name="hubert",
|
|
180
|
+
model_variant="base",
|
|
181
|
+
resampler_type="torchaudio",
|
|
182
|
+
resampler_preset="kaiser-best",
|
|
183
|
+
device="cpu",
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
# Note: The model weights are automatically loaded during the first call to extractor(),
|
|
187
|
+
# so calling extractor.load() explicitly is optional.
|
|
188
|
+
extractor.load()
|
|
189
|
+
|
|
190
|
+
# Extract features.
|
|
191
|
+
features = extractor(waveform, sample_rate)
|
|
192
|
+
print(f"Shape: {features.shape}") # (1, 50, 768)
|
|
193
|
+
|
|
194
|
+
# You can access the features as a Numpy array.
|
|
195
|
+
print(type(features.array)) # <class 'numpy.ndarray'>
|
|
196
|
+
|
|
197
|
+
# You can also access the features as a Torch tensor.
|
|
198
|
+
print(type(features.tensor)) # <class 'torch.Tensor'>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Layer Selection
|
|
202
|
+
|
|
203
|
+
`lfeats` allows you to extract features from specific layer(s).
|
|
204
|
+
By default, the last layer is used.
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
import lfeats
|
|
208
|
+
import numpy as np
|
|
209
|
+
|
|
210
|
+
sample_rate = 16000
|
|
211
|
+
waveform = np.random.uniform(-1, 1, sample_rate)
|
|
212
|
+
|
|
213
|
+
extractor = lfeats.Extractor(model_name="hubert")
|
|
214
|
+
|
|
215
|
+
# Get the second-to-last layer output.
|
|
216
|
+
features = extractor(waveform, sample_rate, layers=-2)
|
|
217
|
+
print(f"Shape: {features.shape}") # (1, 50, 768)
|
|
218
|
+
|
|
219
|
+
# Get the multiple layer outputs.
|
|
220
|
+
features = extractor(waveform, sample_rate, layers=(11, 12))
|
|
221
|
+
print(f"Shape: {features.shape}") # (1, 50, 1536)
|
|
222
|
+
|
|
223
|
+
# Get all layer outputs as a concatenated vector.
|
|
224
|
+
features = extractor(waveform, sample_rate, layers="all")
|
|
225
|
+
print(f"Shape: {features.shape}") # (1, 50, 9984)
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Audio Chuking
|
|
229
|
+
|
|
230
|
+
To be computationally efficient and prevent mismatches between training and inference,
|
|
231
|
+
long audio files can be processed by splitting them into chunks.
|
|
232
|
+
|
|
233
|
+
```python
|
|
234
|
+
import lfeats
|
|
235
|
+
import numpy as np
|
|
236
|
+
|
|
237
|
+
sample_rate = 16000
|
|
238
|
+
waveform = np.random.uniform(-1, 1, 10 * sample_rate)
|
|
239
|
+
|
|
240
|
+
extractor = lfeats.Extractor(model_name="hubert")
|
|
241
|
+
|
|
242
|
+
# Processing a 10-second waveform with a 5-second chunk and 1-second overlap.
|
|
243
|
+
features = extractor(waveform, sample_rate, chunk_length_sec=5, overlap_length_sec=1)
|
|
244
|
+
print(f"Shape: {features.shape}") # (1, 500, 768)
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Sliding-Window Upsampling
|
|
248
|
+
|
|
249
|
+
Since the frame rate of speech foundation models is typically 20ms,
|
|
250
|
+
it often doesn't match the 5ms requirement of speech generation tasks.
|
|
251
|
+
`lfeats` bridges this gap by sliding the input waveform and interleaving the resulting features,
|
|
252
|
+
providing a high-resolution output.
|
|
253
|
+
|
|
254
|
+
```python
|
|
255
|
+
import lfeats
|
|
256
|
+
import numpy as np
|
|
257
|
+
|
|
258
|
+
sample_rate = 16000
|
|
259
|
+
waveform = np.random.uniform(-1, 1, sample_rate)
|
|
260
|
+
|
|
261
|
+
extractor = lfeats.Extractor(model_name="hubert")
|
|
262
|
+
|
|
263
|
+
# Extract features at a 5ms frame rate.
|
|
264
|
+
features = extractor(waveform, sample_rate, upsample_factor=4)
|
|
265
|
+
print(f"Shape: {features.shape}") # (1, 200, 768)
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Utterance-Level Feature Extraction
|
|
269
|
+
|
|
270
|
+
`lfeats` can extract utterance-level features, e.g., speaker embeddings, as well as frame-level features.
|
|
271
|
+
|
|
272
|
+
```python
|
|
273
|
+
import lfeats
|
|
274
|
+
import numpy as np
|
|
275
|
+
|
|
276
|
+
sample_rate = 16000
|
|
277
|
+
waveform = np.random.uniform(-1, 1, sample_rate)
|
|
278
|
+
|
|
279
|
+
extractor = lfeats.Extractor(model_name="ecapa-tdnn")
|
|
280
|
+
|
|
281
|
+
# The default aggregation method for utterance-level features is averaging.
|
|
282
|
+
features = extractor(waveform, sample_rate, overlap_length_sec=0, reduction="mean")
|
|
283
|
+
print(f"Shape: {features.shape}") # (1, 1, 192)
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Command-line Interface
|
|
287
|
+
|
|
288
|
+
Once installed via pip, you can use the `lfeats` command directly from your terminal.
|
|
289
|
+
|
|
290
|
+
```sh
|
|
291
|
+
# Basic usage: extract features from a wav file
|
|
292
|
+
$ lfeats input.wav --output_format npz
|
|
293
|
+
|
|
294
|
+
# Process all audio files in a directory
|
|
295
|
+
$ lfeats input/dir --output_dir feats
|
|
296
|
+
|
|
297
|
+
# Process files listed in a file
|
|
298
|
+
$ lfeats input.scp --output_dir feats
|
|
299
|
+
|
|
300
|
+
# Specify model and layer
|
|
301
|
+
$ lfeats input.wav --model_name hubert --model_variant base --layer 12
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
> [!TIP]
|
|
305
|
+
> For more details on all available flags and default values, simply run:
|
|
306
|
+
>
|
|
307
|
+
> ```sh
|
|
308
|
+
> $ lfeats --help
|
|
309
|
+
> ```
|
|
310
|
+
|
|
311
|
+
## License
|
|
312
|
+
|
|
313
|
+
This project is released under the MIT License.
|
|
314
|
+
|
|
315
|
+
### Third-Party Licenses
|
|
316
|
+
|
|
317
|
+
`lfeats` partially incorporates the following repositories:
|
|
318
|
+
|
|
319
|
+
| Repository | License |
|
|
320
|
+
| :--- | :--- |
|
|
321
|
+
| [fairseq](https://github.com/facebookresearch/fairseq) | MIT |
|
|
322
|
+
| [NeXt_TDNN_ASV](https://github.com/dmlguq456/NeXt_TDNN_ASV) | Apache-2.0 |
|
|
323
|
+
| [R-Spin](https://github.com/vectominist/rspin) | MIT |
|
|
324
|
+
| [S3PRL](https://github.com/s3prl/s3prl) | Apache-2.0 |
|
|
325
|
+
| [SpeechBrain](https://github.com/speechbrain/speechbrain) | Apache-2.0 |
|
|
326
|
+
| [Spin](https://github.com/vectominist/spin) | MIT |
|
|
327
|
+
| [timm](https://github.com/huggingface/pytorch-image-models) | Apache-2.0 |
|
lfeats-0.1.2/README.md
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# lfeats
|
|
2
|
+
|
|
3
|
+
*lfeats* provides a unified interface to extract hidden representations from various speech foundation models such as HuBERT and Whisper.
|
|
4
|
+
While these extracted features are task-independent, the package is primarily designed for speech generation tasks including text-to-speech and voice conversion.
|
|
5
|
+
|
|
6
|
+
[](https://github.com/astral-sh/ruff)
|
|
7
|
+
|
|
8
|
+
## Requirements
|
|
9
|
+
|
|
10
|
+
- Python 3.10+
|
|
11
|
+
- PyTorch 2.6.0+
|
|
12
|
+
|
|
13
|
+
## Documentation
|
|
14
|
+
|
|
15
|
+
- [**Reference Manual**](https://takenori-y.github.io/lfeats/0.1.2/)
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
The latest stable release can be installed via PyPI:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
pip install lfeats
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Alternatively, the development version can be installed directly from the GitHub repository:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
pip install git+https://github.com/takenori-y/lfeats.git@master
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Supported Models
|
|
32
|
+
|
|
33
|
+
### Frame-Level Features
|
|
34
|
+
|
|
35
|
+
| Model Name | Model Variant | Layers | Dimension | Paper | Source | Model Hub |
|
|
36
|
+
| :--- | :--- | ---: | ---: | :---: | :---: | :---: |
|
|
37
|
+
| `contentvec` | `hubert-100` | 12 | 768 | [arXiv](https://arxiv.org/abs/2204.09224) | [GitHub](https://github.com/auspicious3000/contentvec) | |
|
|
38
|
+
| | `hubert-500` | 12 | 768 | | | |
|
|
39
|
+
| `data2vec` | `base` | 12 | 768 | [arXiv](https://arxiv.org/abs/2202.03555) | [GitHub](https://github.com/facebookresearch/fairseq/tree/main/examples/data2vec) | |
|
|
40
|
+
| | `large` | 24 | 1024 | | | |
|
|
41
|
+
| `data2vec2` | `base` | 8 | 768 | [arXiv](https://arxiv.org/abs/2212.07525) | [GitHub](https://github.com/facebookresearch/fairseq/tree/main/examples/data2vec) | |
|
|
42
|
+
| | `large` | 16 | 1024 | | | |
|
|
43
|
+
| `hubert` | `base` | 12 | 768 | [arXiv](https://arxiv.org/abs/2106.07447) | [GitHub](https://github.com/facebookresearch/fairseq/tree/main/examples/hubert) | [🤗](https://huggingface.co/facebook/hubert-base-ls960) |
|
|
44
|
+
| | `large` | 24 | 1024 | | | [🤗](https://huggingface.co/facebook/hubert-large-ll60k) |
|
|
45
|
+
| | `xlarge` | 48 | 1280 | | | [🤗](https://huggingface.co/facebook/hubert-xlarge-ll60k) |
|
|
46
|
+
| `r-spin` | `wavlm-32` | 12 | 768 | [arXiv](https://arxiv.org/abs/2311.09117) | [GitHub](https://github.com/vectominist/rspin) | |
|
|
47
|
+
| | `wavlm-64` | 12 | 768 | | | |
|
|
48
|
+
| | `wavlm-128` | 12 | 768 | | | |
|
|
49
|
+
| | `wavlm-256` | 12 | 768 | | | |
|
|
50
|
+
| | `wavlm-512` | 12 | 768 | | | |
|
|
51
|
+
| | `wavlm-1024` | 12 | 768 | | | |
|
|
52
|
+
| | `wavlm-2048` | 12 | 768 | | | |
|
|
53
|
+
| `spidr` | `base` | 12 | 768 | [arXiv](https://arxiv.org/abs/2512.20308) | [GitHub](https://github.com/facebookresearch/spidr) | |
|
|
54
|
+
| `spin` | `hubert-128` | 12 | 768 | [arXiv](https://arxiv.org/abs/2305.11072) | [GitHub](https://github.com/vectominist/spin) | |
|
|
55
|
+
| | `hubert-256` | 12 | 768 | | | |
|
|
56
|
+
| | `hubert-512` | 12 | 768 | | | |
|
|
57
|
+
| | `hubert-1024` | 12 | 768 | | | |
|
|
58
|
+
| | `hubert-2048` | 12 | 768 | | | |
|
|
59
|
+
| | `wavlm-128` | 12 | 768 | | | |
|
|
60
|
+
| | `wavlm-256` | 12 | 768 | | | |
|
|
61
|
+
| | `wavlm-512` | 12 | 768 | | | |
|
|
62
|
+
| | `wavlm-1024` | 12 | 768 | | | |
|
|
63
|
+
| | `wavlm-2048` | 12 | 768 | | | |
|
|
64
|
+
| `sslzip` | `tiny` | 0 | 16 | [ISCA](https://www.isca-archive.org/ssw_2025/yoshimura25_ssw.html) | [GitHub](https://github.com/sp-nitech/SSLZip) | [🤗](https://huggingface.co/takenori-y/SSLZip-16) |
|
|
65
|
+
| | `base` | 0 | 256 | | | [🤗](https://huggingface.co/takenori-y/SSLZip-256) |
|
|
66
|
+
| `unispeech-sat` | `base` | 12 | 768 | [arXiv](https://arxiv.org/abs/2110.05752) | [GitHub](https://github.com/microsoft/UniSpeech) | [🤗](https://huggingface.co/microsoft/unispeech-sat-base) |
|
|
67
|
+
| | `base-plus` | 12 | 768 | | | [🤗](https://huggingface.co/microsoft/unispeech-sat-base-plus) |
|
|
68
|
+
| | `large` | 24 | 1024 | | | [🤗](https://huggingface.co/microsoft/unispeech-sat-large) |
|
|
69
|
+
| `wav2vec2` | `base` | 12 | 768 | [arXiv](https://arxiv.org/abs/2006.11477) | [GitHub](https://github.com/facebookresearch/fairseq/tree/main/examples/wav2vec) | |
|
|
70
|
+
| | `large` | 24 | 1024 | | | |
|
|
71
|
+
| | `xlsr` | 24 | 1024 | [arXiv](https://arxiv.org/abs/2006.13979) | | |
|
|
72
|
+
| | `xlsr-v2` | 24 | 1024 | [arXiv](https://arxiv.org/abs/2111.09296) | [GitHub](https://github.com/facebookresearch/fairseq/tree/main/examples/wav2vec/xlsr) | |
|
|
73
|
+
| `wavlm` | `base` | 12 | 768 | [arXiv](https://arxiv.org/abs/2110.13900) | [GitHub](https://github.com/microsoft/unilm/tree/master/wavlm) | [🤗](https://huggingface.co/microsoft/wavlm-base) |
|
|
74
|
+
| | `base-plus` | 12 | 768 | | | [🤗](https://huggingface.co/microsoft/wavlm-base-plus) |
|
|
75
|
+
| | `large` | 24 | 1024 | | | [🤗](https://huggingface.co/microsoft/wavlm-large) |
|
|
76
|
+
| `whisper` | `tiny` | 4 | 384 | [arXiv](https://arxiv.org/abs/2212.04356) | [GitHub](https://github.com/openai/whisper) | [🤗](https://huggingface.co/openai/whisper-tiny) |
|
|
77
|
+
| | `base` | 6 | 512 | | | [🤗](https://huggingface.co/openai/whisper-base) |
|
|
78
|
+
| | `small` | 12 | 768 | | | [🤗](https://huggingface.co/openai/whisper-small) |
|
|
79
|
+
| | `medium` | 24 | 1024 | | | [🤗](https://huggingface.co/openai/whisper-medium) |
|
|
80
|
+
| | `large` | 32 | 1280 | | | [🤗](https://huggingface.co/openai/whisper-large) |
|
|
81
|
+
| | `large-v2` | 32 | 1280 | | | [🤗](https://huggingface.co/openai/whisper-large-v2) |
|
|
82
|
+
| | `large-v3` | 32 | 1280 | | | [🤗](https://huggingface.co/openai/whisper-large-v3) |
|
|
83
|
+
|
|
84
|
+
### Utterance-Level Features
|
|
85
|
+
|
|
86
|
+
| Model Name | Model Variant | Layers | Dimension | Paper | Source | Model Hub |
|
|
87
|
+
| :--- | :--- | ---: | ---: | :---: | :---: | :---: |
|
|
88
|
+
| `ecapa-tdnn` | `base` | 0 | 192 | [arXiv](https://arxiv.org/abs/2005.07143) | [GitHub](https://github.com/speechbrain/speechbrain) | [🤗](https://huggingface.co/speechbrain/spkrec-ecapa-voxceleb) |
|
|
89
|
+
| `next-tdnn` | `light` | 0 | 192 | [arXiv](https://arxiv.org/abs/2312.08603) | [GitHub](https://github.com/dmlguq456/NeXt_TDNN_ASV) | |
|
|
90
|
+
| | `base` | 0 | 192 | | | |
|
|
91
|
+
| | `base-v2` | 0 | 192 | | | |
|
|
92
|
+
| `r-vector` | `base` | 0 | 256 | [arXiv](https://arxiv.org/pdf/1910.12592) | [GitHub](https://github.com/speechbrain/speechbrain) | [🤗](https://huggingface.co/speechbrain/spkrec-resnet-voxceleb) |
|
|
93
|
+
| `x-vector` | `base` | 0 | 512 | [IEEE](https://ieeexplore.ieee.org/document/8461375) | [GitHub](https://github.com/speechbrain/speechbrain) | [🤗](https://huggingface.co/speechbrain/spkrec-xvect-voxceleb) |
|
|
94
|
+
|
|
95
|
+
> [!IMPORTANT]
|
|
96
|
+
> Users must comply with the respective licenses of the models.
|
|
97
|
+
> Please refer to the original repositories for detailed licensing information.
|
|
98
|
+
|
|
99
|
+
## Supported Resamplers
|
|
100
|
+
|
|
101
|
+
| Resampler Type | Quality Preset | Source | License |
|
|
102
|
+
| :--- | :--- | :---: | :--- |
|
|
103
|
+
| `lilfilter` | `base` | [GitHub](https://github.com/danpovey/filtering) | MIT |
|
|
104
|
+
| `soxr` | `quick` | [GitHub](https://github.com/dofuuz/python-soxr) | LGPL v2.1+ |
|
|
105
|
+
| | `low` | | |
|
|
106
|
+
| | `medium` | | |
|
|
107
|
+
| | `high` | | |
|
|
108
|
+
| | `very-high` | | |
|
|
109
|
+
| `torchaudio` | `kaiser-fast` | [GitHub](https://github.com/pytorch/audio) | BSD 2-Clause |
|
|
110
|
+
| | `kaiser-best` | | |
|
|
111
|
+
|
|
112
|
+
## Examples
|
|
113
|
+
|
|
114
|
+
### Simple Usage
|
|
115
|
+
|
|
116
|
+
`lfeats` simplifies the process of extracting hidden states from various speech foundation models.
|
|
117
|
+
You don't need to worry about differences between model types or input/output data types.
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
import lfeats
|
|
121
|
+
import numpy as np
|
|
122
|
+
|
|
123
|
+
# Prepare an audio waveform without zero-mean and unit-variance normalization.
|
|
124
|
+
# Either a NumPy array or a Torch tensor are accepted as the input of the extractor.
|
|
125
|
+
sample_rate = 16000
|
|
126
|
+
waveform = np.random.uniform(-1, 1, sample_rate)
|
|
127
|
+
|
|
128
|
+
# Initialize the extractor.
|
|
129
|
+
extractor = lfeats.Extractor(
|
|
130
|
+
model_name="hubert",
|
|
131
|
+
model_variant="base",
|
|
132
|
+
resampler_type="torchaudio",
|
|
133
|
+
resampler_preset="kaiser-best",
|
|
134
|
+
device="cpu",
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
# Note: The model weights are automatically loaded during the first call to extractor(),
|
|
138
|
+
# so calling extractor.load() explicitly is optional.
|
|
139
|
+
extractor.load()
|
|
140
|
+
|
|
141
|
+
# Extract features.
|
|
142
|
+
features = extractor(waveform, sample_rate)
|
|
143
|
+
print(f"Shape: {features.shape}") # (1, 50, 768)
|
|
144
|
+
|
|
145
|
+
# You can access the features as a Numpy array.
|
|
146
|
+
print(type(features.array)) # <class 'numpy.ndarray'>
|
|
147
|
+
|
|
148
|
+
# You can also access the features as a Torch tensor.
|
|
149
|
+
print(type(features.tensor)) # <class 'torch.Tensor'>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Layer Selection
|
|
153
|
+
|
|
154
|
+
`lfeats` allows you to extract features from specific layer(s).
|
|
155
|
+
By default, the last layer is used.
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
import lfeats
|
|
159
|
+
import numpy as np
|
|
160
|
+
|
|
161
|
+
sample_rate = 16000
|
|
162
|
+
waveform = np.random.uniform(-1, 1, sample_rate)
|
|
163
|
+
|
|
164
|
+
extractor = lfeats.Extractor(model_name="hubert")
|
|
165
|
+
|
|
166
|
+
# Get the second-to-last layer output.
|
|
167
|
+
features = extractor(waveform, sample_rate, layers=-2)
|
|
168
|
+
print(f"Shape: {features.shape}") # (1, 50, 768)
|
|
169
|
+
|
|
170
|
+
# Get the multiple layer outputs.
|
|
171
|
+
features = extractor(waveform, sample_rate, layers=(11, 12))
|
|
172
|
+
print(f"Shape: {features.shape}") # (1, 50, 1536)
|
|
173
|
+
|
|
174
|
+
# Get all layer outputs as a concatenated vector.
|
|
175
|
+
features = extractor(waveform, sample_rate, layers="all")
|
|
176
|
+
print(f"Shape: {features.shape}") # (1, 50, 9984)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Audio Chuking
|
|
180
|
+
|
|
181
|
+
To be computationally efficient and prevent mismatches between training and inference,
|
|
182
|
+
long audio files can be processed by splitting them into chunks.
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
import lfeats
|
|
186
|
+
import numpy as np
|
|
187
|
+
|
|
188
|
+
sample_rate = 16000
|
|
189
|
+
waveform = np.random.uniform(-1, 1, 10 * sample_rate)
|
|
190
|
+
|
|
191
|
+
extractor = lfeats.Extractor(model_name="hubert")
|
|
192
|
+
|
|
193
|
+
# Processing a 10-second waveform with a 5-second chunk and 1-second overlap.
|
|
194
|
+
features = extractor(waveform, sample_rate, chunk_length_sec=5, overlap_length_sec=1)
|
|
195
|
+
print(f"Shape: {features.shape}") # (1, 500, 768)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Sliding-Window Upsampling
|
|
199
|
+
|
|
200
|
+
Since the frame rate of speech foundation models is typically 20ms,
|
|
201
|
+
it often doesn't match the 5ms requirement of speech generation tasks.
|
|
202
|
+
`lfeats` bridges this gap by sliding the input waveform and interleaving the resulting features,
|
|
203
|
+
providing a high-resolution output.
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
import lfeats
|
|
207
|
+
import numpy as np
|
|
208
|
+
|
|
209
|
+
sample_rate = 16000
|
|
210
|
+
waveform = np.random.uniform(-1, 1, sample_rate)
|
|
211
|
+
|
|
212
|
+
extractor = lfeats.Extractor(model_name="hubert")
|
|
213
|
+
|
|
214
|
+
# Extract features at a 5ms frame rate.
|
|
215
|
+
features = extractor(waveform, sample_rate, upsample_factor=4)
|
|
216
|
+
print(f"Shape: {features.shape}") # (1, 200, 768)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Utterance-Level Feature Extraction
|
|
220
|
+
|
|
221
|
+
`lfeats` can extract utterance-level features, e.g., speaker embeddings, as well as frame-level features.
|
|
222
|
+
|
|
223
|
+
```python
|
|
224
|
+
import lfeats
|
|
225
|
+
import numpy as np
|
|
226
|
+
|
|
227
|
+
sample_rate = 16000
|
|
228
|
+
waveform = np.random.uniform(-1, 1, sample_rate)
|
|
229
|
+
|
|
230
|
+
extractor = lfeats.Extractor(model_name="ecapa-tdnn")
|
|
231
|
+
|
|
232
|
+
# The default aggregation method for utterance-level features is averaging.
|
|
233
|
+
features = extractor(waveform, sample_rate, overlap_length_sec=0, reduction="mean")
|
|
234
|
+
print(f"Shape: {features.shape}") # (1, 1, 192)
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Command-line Interface
|
|
238
|
+
|
|
239
|
+
Once installed via pip, you can use the `lfeats` command directly from your terminal.
|
|
240
|
+
|
|
241
|
+
```sh
|
|
242
|
+
# Basic usage: extract features from a wav file
|
|
243
|
+
$ lfeats input.wav --output_format npz
|
|
244
|
+
|
|
245
|
+
# Process all audio files in a directory
|
|
246
|
+
$ lfeats input/dir --output_dir feats
|
|
247
|
+
|
|
248
|
+
# Process files listed in a file
|
|
249
|
+
$ lfeats input.scp --output_dir feats
|
|
250
|
+
|
|
251
|
+
# Specify model and layer
|
|
252
|
+
$ lfeats input.wav --model_name hubert --model_variant base --layer 12
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
> [!TIP]
|
|
256
|
+
> For more details on all available flags and default values, simply run:
|
|
257
|
+
>
|
|
258
|
+
> ```sh
|
|
259
|
+
> $ lfeats --help
|
|
260
|
+
> ```
|
|
261
|
+
|
|
262
|
+
## License
|
|
263
|
+
|
|
264
|
+
This project is released under the MIT License.
|
|
265
|
+
|
|
266
|
+
### Third-Party Licenses
|
|
267
|
+
|
|
268
|
+
`lfeats` partially incorporates the following repositories:
|
|
269
|
+
|
|
270
|
+
| Repository | License |
|
|
271
|
+
| :--- | :--- |
|
|
272
|
+
| [fairseq](https://github.com/facebookresearch/fairseq) | MIT |
|
|
273
|
+
| [NeXt_TDNN_ASV](https://github.com/dmlguq456/NeXt_TDNN_ASV) | Apache-2.0 |
|
|
274
|
+
| [R-Spin](https://github.com/vectominist/rspin) | MIT |
|
|
275
|
+
| [S3PRL](https://github.com/s3prl/s3prl) | Apache-2.0 |
|
|
276
|
+
| [SpeechBrain](https://github.com/speechbrain/speechbrain) | Apache-2.0 |
|
|
277
|
+
| [Spin](https://github.com/vectominist/spin) | MIT |
|
|
278
|
+
| [timm](https://github.com/huggingface/pytorch-image-models) | Apache-2.0 |
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Copyright (c) 2026 Takenori Yoshimura
|
|
2
|
+
# Released under the MIT License.
|
|
3
|
+
|
|
4
|
+
"""The main module for the audio feature extraction package."""
|
|
5
|
+
|
|
6
|
+
from .interfaces.extractor import Extractor
|
|
7
|
+
from .interfaces.resampler import Resampler
|
|
8
|
+
from .interfaces.types import Audio, Container, Features
|
|
9
|
+
from .version import __version__
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"Audio",
|
|
13
|
+
"Container",
|
|
14
|
+
"Extractor",
|
|
15
|
+
"Features",
|
|
16
|
+
"Resampler",
|
|
17
|
+
"__version__",
|
|
18
|
+
]
|