justdata 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- justdata/__init__.py +3 -0
- justdata/acoustic/__init__.py +381 -0
- justdata/acoustic/adapters.py +329 -0
- justdata/acoustic/augment/__init__.py +119 -0
- justdata/acoustic/augment/batch.py +813 -0
- justdata/acoustic/augment/configs.py +204 -0
- justdata/acoustic/augment/patchout.py +331 -0
- justdata/acoustic/augment/spectrogram.py +806 -0
- justdata/acoustic/augment/waveform.py +879 -0
- justdata/acoustic/batching.py +27 -0
- justdata/acoustic/channel.py +53 -0
- justdata/acoustic/compat/__init__.py +95 -0
- justdata/acoustic/compat/ast.py +626 -0
- justdata/acoustic/compat/ced.py +152 -0
- justdata/acoustic/compat/efficientat.py +243 -0
- justdata/acoustic/compat/panns.py +115 -0
- justdata/acoustic/compat/passt.py +191 -0
- justdata/acoustic/configs.py +519 -0
- justdata/acoustic/corruptions/__init__.py +33 -0
- justdata/acoustic/corruptions/codec.py +92 -0
- justdata/acoustic/corruptions/datasets.py +155 -0
- justdata/acoustic/corruptions/device.py +39 -0
- justdata/acoustic/corruptions/dynamics.py +55 -0
- justdata/acoustic/corruptions/filters.py +105 -0
- justdata/acoustic/corruptions/noise.py +173 -0
- justdata/acoustic/corruptions/registry.py +230 -0
- justdata/acoustic/corruptions/reverb.py +49 -0
- justdata/acoustic/corruptions/timefreq.py +127 -0
- justdata/acoustic/datasets.py +52 -0
- justdata/acoustic/dcase2025.py +814 -0
- justdata/acoustic/decoding.py +73 -0
- justdata/acoustic/eval_views.py +54 -0
- justdata/acoustic/evals.py +71 -0
- justdata/acoustic/filters.py +18 -0
- justdata/acoustic/frontends/__init__.py +37 -0
- justdata/acoustic/frontends/ast.py +116 -0
- justdata/acoustic/frontends/kaldi.py +34 -0
- justdata/acoustic/frontends/log.py +94 -0
- justdata/acoustic/frontends/mel.py +173 -0
- justdata/acoustic/frontends/mfcc.py +26 -0
- justdata/acoustic/frontends/pcen.py +26 -0
- justdata/acoustic/frontends/stft.py +174 -0
- justdata/acoustic/jax.py +23 -0
- justdata/acoustic/labels.py +169 -0
- justdata/acoustic/layouts.py +86 -0
- justdata/acoustic/metadata.py +152 -0
- justdata/acoustic/normalization.py +196 -0
- justdata/acoustic/pipelines.py +112 -0
- justdata/acoustic/postprocessing.py +328 -0
- justdata/acoustic/preprocessing.py +175 -0
- justdata/acoustic/presets.py +257 -0
- justdata/acoustic/registry.py +381 -0
- justdata/acoustic/resampling.py +218 -0
- justdata/acoustic/schema.py +51 -0
- justdata/acoustic/segment.py +369 -0
- justdata/acoustic/sources.py +503 -0
- justdata/acoustic/stages.py +59 -0
- justdata/acoustic/stats.py +50 -0
- justdata/acoustic/tasks.py +375 -0
- justdata/audio/__init__.py +20 -0
- justdata/core/__init__.py +74 -0
- justdata/core/adapters.py +46 -0
- justdata/core/augmentations.py +34 -0
- justdata/core/filters.py +94 -0
- justdata/core/finalization.py +173 -0
- justdata/core/label_mixing.py +129 -0
- justdata/core/loader.py +384 -0
- justdata/core/metadata.py +250 -0
- justdata/core/presets.py +155 -0
- justdata/core/registry.py +229 -0
- justdata/core/sources.py +87 -0
- justdata/core/stats.py +227 -0
- justdata/corruptions.py +52 -0
- justdata/py.typed +0 -0
- justdata/vision/__init__.py +17 -0
- justdata/vision/augmentations/__init__.py +31 -0
- justdata/vision/augmentations/auto.py +480 -0
- justdata/vision/augmentations/color.py +163 -0
- justdata/vision/augmentations/composed.py +156 -0
- justdata/vision/augmentations/geometric.py +302 -0
- justdata/vision/augmentations/mixing.py +232 -0
- justdata/vision/augmentations/registry.py +142 -0
- justdata/vision/corruptions/__init__.py +16 -0
- justdata/vision/corruptions/blur.py +65 -0
- justdata/vision/corruptions/digital.py +26 -0
- justdata/vision/corruptions/noise.py +20 -0
- justdata/vision/corruptions/registry.py +113 -0
- justdata/vision/corruptions/weather.py +100 -0
- justdata/vision/datasets.py +34 -0
- justdata/vision/encodings/__init__.py +1 -0
- justdata/vision/encodings/heatmaps.py +196 -0
- justdata/vision/minic.py +69 -0
- justdata/vision/pipelines.py +62 -0
- justdata/vision/presets.py +509 -0
- justdata/vision/sources.py +1080 -0
- justdata/vision/stages.py +271 -0
- justdata/vision/tasks/__init__.py +1 -0
- justdata/vision/tasks/classification.py +321 -0
- justdata/vision/tasks/depth.py +25 -0
- justdata/vision/tasks/segmentation.py +194 -0
- justdata/vision/transforms.py +113 -0
- justdata/vision/utils.py +741 -0
- justdata-1.0.0.dist-info/METADATA +860 -0
- justdata-1.0.0.dist-info/RECORD +106 -0
- justdata-1.0.0.dist-info/WHEEL +4 -0
- justdata-1.0.0.dist-info/licenses/LICENSE +23 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Callable, Mapping
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
import tensorflow as tf
|
|
7
|
+
|
|
8
|
+
from justdata.acoustic.adapters import (
|
|
9
|
+
infer_duration,
|
|
10
|
+
standardize_waveform_layout,
|
|
11
|
+
to_float32_waveform,
|
|
12
|
+
)
|
|
13
|
+
from justdata.acoustic.channel import apply_channel_strategy
|
|
14
|
+
from justdata.acoustic.configs import AudioPreprocessConfig
|
|
15
|
+
from justdata.acoustic.decoding import decode_audio_file
|
|
16
|
+
from justdata.acoustic.resampling import resample_waveform
|
|
17
|
+
from justdata.acoustic.schema import (
|
|
18
|
+
AUDIO,
|
|
19
|
+
DURATION,
|
|
20
|
+
METADATA,
|
|
21
|
+
ORIGINAL_SAMPLE_RATE,
|
|
22
|
+
PATH,
|
|
23
|
+
SAMPLE_RATE,
|
|
24
|
+
WAVEFORM,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def remove_dc_offset(audio: tf.Tensor) -> tf.Tensor:
|
|
29
|
+
audio = tf.convert_to_tensor(audio, dtype=tf.float32)
|
|
30
|
+
return audio - tf.reduce_mean(audio, axis=0, keepdims=True)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def normalize_waveform(audio: tf.Tensor, mode: str) -> tf.Tensor:
|
|
34
|
+
audio = tf.convert_to_tensor(audio, dtype=tf.float32)
|
|
35
|
+
eps = tf.constant(1e-8, dtype=tf.float32)
|
|
36
|
+
|
|
37
|
+
if mode == "none":
|
|
38
|
+
return audio
|
|
39
|
+
if mode == "peak":
|
|
40
|
+
peak = tf.reduce_max(tf.abs(audio))
|
|
41
|
+
return tf.math.divide_no_nan(audio, tf.maximum(peak, eps))
|
|
42
|
+
if mode == "rms":
|
|
43
|
+
rms = tf.sqrt(tf.reduce_mean(tf.square(audio)))
|
|
44
|
+
return tf.math.divide_no_nan(audio, tf.maximum(rms, eps))
|
|
45
|
+
if mode == "lufs":
|
|
46
|
+
raise ValueError(
|
|
47
|
+
"normalize_waveform='lufs' requires an explicit loudness target; "
|
|
48
|
+
"use 'peak' or 'rms' for built-in deterministic normalization."
|
|
49
|
+
)
|
|
50
|
+
raise ValueError(f"Unknown waveform normalization mode: {mode!r}")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _metadata_from(sample: dict) -> dict:
|
|
54
|
+
metadata = sample.get(METADATA)
|
|
55
|
+
return dict(metadata) if isinstance(metadata, dict) else {}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _get_from_audio_payload(audio_payload: Any, key: str) -> Any | None:
|
|
59
|
+
if isinstance(audio_payload, Mapping):
|
|
60
|
+
return audio_payload.get(key)
|
|
61
|
+
return None
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _extract_audio(sample: dict) -> tuple[tf.Tensor, tf.Tensor | None]:
|
|
65
|
+
if WAVEFORM in sample:
|
|
66
|
+
return tf.convert_to_tensor(sample[WAVEFORM]), None
|
|
67
|
+
|
|
68
|
+
audio_payload = sample.get(AUDIO)
|
|
69
|
+
if isinstance(audio_payload, Mapping):
|
|
70
|
+
waveform = audio_payload.get("array", audio_payload.get(WAVEFORM))
|
|
71
|
+
sample_rate = audio_payload.get(SAMPLE_RATE, audio_payload.get("sampling_rate"))
|
|
72
|
+
if waveform is not None:
|
|
73
|
+
return tf.convert_to_tensor(waveform), sample_rate
|
|
74
|
+
if audio_payload is not None:
|
|
75
|
+
return tf.convert_to_tensor(audio_payload), None
|
|
76
|
+
|
|
77
|
+
if PATH in sample:
|
|
78
|
+
return decode_audio_file(sample[PATH])
|
|
79
|
+
|
|
80
|
+
raise ValueError(
|
|
81
|
+
f"Acoustic sample must contain '{WAVEFORM}', '{AUDIO}', or '{PATH}'."
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _extract_sample_rate(
|
|
86
|
+
sample: dict,
|
|
87
|
+
audio_payload: Any,
|
|
88
|
+
decoded_sample_rate: tf.Tensor | None,
|
|
89
|
+
) -> tf.Tensor:
|
|
90
|
+
sample_rate = sample.get(SAMPLE_RATE)
|
|
91
|
+
if sample_rate is None:
|
|
92
|
+
sample_rate = sample.get("sampling_rate")
|
|
93
|
+
if sample_rate is None:
|
|
94
|
+
sample_rate = _get_from_audio_payload(audio_payload, SAMPLE_RATE)
|
|
95
|
+
if sample_rate is None:
|
|
96
|
+
sample_rate = _get_from_audio_payload(audio_payload, "sampling_rate")
|
|
97
|
+
if sample_rate is None:
|
|
98
|
+
sample_rate = decoded_sample_rate
|
|
99
|
+
if sample_rate is None:
|
|
100
|
+
raise ValueError("Acoustic sample is missing a sample rate.")
|
|
101
|
+
return tf.cast(sample_rate, tf.int32)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def _extract_original_sample_rate(sample: dict, sample_rate: tf.Tensor) -> tf.Tensor:
|
|
105
|
+
metadata = sample.get(METADATA)
|
|
106
|
+
original_sample_rate = sample.get(ORIGINAL_SAMPLE_RATE)
|
|
107
|
+
if original_sample_rate is None and isinstance(metadata, dict):
|
|
108
|
+
original_sample_rate = metadata.get(ORIGINAL_SAMPLE_RATE)
|
|
109
|
+
if original_sample_rate is None:
|
|
110
|
+
original_sample_rate = sample_rate
|
|
111
|
+
return tf.cast(original_sample_rate, tf.int32)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def make_preprocessing(config: AudioPreprocessConfig) -> Callable[[dict], dict]:
|
|
115
|
+
config = AudioPreprocessConfig.from_dict(config)
|
|
116
|
+
|
|
117
|
+
def preprocessing(sample: dict) -> dict:
|
|
118
|
+
waveform, decoded_sample_rate = _extract_audio(sample)
|
|
119
|
+
audio_payload = sample.get(AUDIO)
|
|
120
|
+
sample_rate = _extract_sample_rate(sample, audio_payload, decoded_sample_rate)
|
|
121
|
+
original_sample_rate = _extract_original_sample_rate(sample, sample_rate)
|
|
122
|
+
|
|
123
|
+
input_dtype = waveform.dtype
|
|
124
|
+
audio = to_float32_waveform(waveform, input_dtype=input_dtype)
|
|
125
|
+
audio = standardize_waveform_layout(audio)
|
|
126
|
+
|
|
127
|
+
original_duration = infer_duration(tf.shape(audio)[0], sample_rate)
|
|
128
|
+
|
|
129
|
+
audio = resample_waveform(
|
|
130
|
+
audio,
|
|
131
|
+
sample_rate,
|
|
132
|
+
config.target_sample_rate,
|
|
133
|
+
method=config.resampler,
|
|
134
|
+
)
|
|
135
|
+
sample_rate = tf.cast(config.target_sample_rate, tf.int32)
|
|
136
|
+
|
|
137
|
+
audio = apply_channel_strategy(audio, config.channel_strategy)
|
|
138
|
+
|
|
139
|
+
if config.remove_dc_offset:
|
|
140
|
+
audio = remove_dc_offset(audio)
|
|
141
|
+
|
|
142
|
+
audio = normalize_waveform(audio, config.normalize_waveform)
|
|
143
|
+
|
|
144
|
+
if config.clip_value is not None:
|
|
145
|
+
clip_value = tf.cast(config.clip_value, tf.float32)
|
|
146
|
+
audio = tf.clip_by_value(audio, -clip_value, clip_value)
|
|
147
|
+
|
|
148
|
+
duration = infer_duration(tf.shape(audio)[0], sample_rate)
|
|
149
|
+
|
|
150
|
+
metadata = _metadata_from(sample)
|
|
151
|
+
metadata[ORIGINAL_SAMPLE_RATE] = original_sample_rate
|
|
152
|
+
metadata["original_duration"] = original_duration
|
|
153
|
+
metadata["num_channels"] = tf.shape(audio)[-1]
|
|
154
|
+
metadata["channel_strategy"] = tf.constant(config.channel_strategy)
|
|
155
|
+
metadata[DURATION] = duration
|
|
156
|
+
|
|
157
|
+
result = {
|
|
158
|
+
key: value
|
|
159
|
+
for key, value in sample.items()
|
|
160
|
+
if key not in {AUDIO, WAVEFORM, SAMPLE_RATE, DURATION, METADATA}
|
|
161
|
+
}
|
|
162
|
+
result[WAVEFORM] = audio
|
|
163
|
+
result[SAMPLE_RATE] = sample_rate
|
|
164
|
+
result[DURATION] = duration
|
|
165
|
+
result[METADATA] = metadata
|
|
166
|
+
return result
|
|
167
|
+
|
|
168
|
+
return preprocessing
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
__all__ = [
|
|
172
|
+
"make_preprocessing",
|
|
173
|
+
"normalize_waveform",
|
|
174
|
+
"remove_dc_offset",
|
|
175
|
+
]
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
from typing import Any, Dict
|
|
2
|
+
|
|
3
|
+
from justdata.acoustic.compat.ast import (
|
|
4
|
+
ast_audioset_16k_10s_fbank128,
|
|
5
|
+
ast_esc50_16k_5s_fbank128,
|
|
6
|
+
ast_speechcommands_16k_1s_fbank128,
|
|
7
|
+
)
|
|
8
|
+
from justdata.acoustic.compat.ced import (
|
|
9
|
+
ced_base_16k_logmel64,
|
|
10
|
+
ced_mini_16k_logmel64,
|
|
11
|
+
ced_small_16k_logmel64,
|
|
12
|
+
ced_tiny_16k_logmel64,
|
|
13
|
+
dcase2025_task1_ced_16k_1s,
|
|
14
|
+
)
|
|
15
|
+
from justdata.acoustic.compat.efficientat import (
|
|
16
|
+
dcase2025_task1_dymn_32k_1s,
|
|
17
|
+
dcase2025_task1_efficientat_32k_1s,
|
|
18
|
+
dcase2025_task1_efficientat_32k_1s_repeat_to_10s,
|
|
19
|
+
dcase2025_task1_efficientat_32k_1s_zero_pad_to_10s,
|
|
20
|
+
dymn_32k_10s_logmel128,
|
|
21
|
+
efficientat_32k_10s_logmel128,
|
|
22
|
+
)
|
|
23
|
+
from justdata.acoustic.compat.panns import (
|
|
24
|
+
panns_cnn14_16k_10s_logmel64,
|
|
25
|
+
panns_cnn14_32k_10s_logmel64,
|
|
26
|
+
)
|
|
27
|
+
from justdata.acoustic.compat.passt import (
|
|
28
|
+
dcase2025_task1_passt_32k_1s,
|
|
29
|
+
dcase2025_task1_passt_32k_1s_repeat_to_10s,
|
|
30
|
+
dcase2025_task1_passt_32k_1s_zero_pad_to_10s,
|
|
31
|
+
passt_32k_10s_logmel128,
|
|
32
|
+
)
|
|
33
|
+
from justdata.acoustic.configs import (
|
|
34
|
+
AudioPreprocessConfig,
|
|
35
|
+
AudioPreset,
|
|
36
|
+
FrontendConfig,
|
|
37
|
+
LabelTransformConfig,
|
|
38
|
+
LogCompressionConfig,
|
|
39
|
+
MelConfig,
|
|
40
|
+
STFTConfig,
|
|
41
|
+
SegmentStrategyConfig,
|
|
42
|
+
)
|
|
43
|
+
from justdata.core.presets import (
|
|
44
|
+
ResolvedPreset,
|
|
45
|
+
get_dataset_presets as _get_dataset_presets,
|
|
46
|
+
get_resolved_preset as _get_resolved_preset,
|
|
47
|
+
merge_with_presets as _merge_with_presets,
|
|
48
|
+
register_preset as _register_preset,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def register_preset(dataset: str, config: Dict[str, Any] | AudioPreset):
|
|
53
|
+
if isinstance(config, AudioPreset):
|
|
54
|
+
config = config.to_dict()
|
|
55
|
+
_register_preset(dataset, config, modality="acoustic")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def get_dataset_presets(dataset: str) -> Dict[str, Any]:
|
|
59
|
+
return _get_dataset_presets(dataset, modality="acoustic")
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def get_resolved_preset(dataset: str) -> ResolvedPreset:
|
|
63
|
+
return _get_resolved_preset(dataset, modality="acoustic")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def merge_with_presets(dataset: str, user_kwargs: Dict[str, Any]) -> Dict[str, Any]:
|
|
67
|
+
return _merge_with_presets(dataset, user_kwargs, modality="acoustic")
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _segment(duration: float) -> SegmentStrategyConfig:
|
|
71
|
+
return SegmentStrategyConfig(
|
|
72
|
+
clip_duration=duration,
|
|
73
|
+
train_mode="random_crop",
|
|
74
|
+
eval_mode="center_crop",
|
|
75
|
+
pad_mode="zero",
|
|
76
|
+
pad_position="right",
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _preprocess(sample_rate: int) -> AudioPreprocessConfig:
|
|
81
|
+
return AudioPreprocessConfig(
|
|
82
|
+
target_sample_rate=sample_rate,
|
|
83
|
+
channel_strategy="mono_mean",
|
|
84
|
+
normalize_waveform="none",
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _label(mode: str, num_classes: int | None = None) -> LabelTransformConfig:
|
|
89
|
+
return LabelTransformConfig(mode=mode, num_classes=num_classes)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _logmel_frontend(
|
|
93
|
+
*,
|
|
94
|
+
sample_rate: int,
|
|
95
|
+
n_fft: int,
|
|
96
|
+
win_length: int,
|
|
97
|
+
hop_length: int,
|
|
98
|
+
n_mels: int,
|
|
99
|
+
f_max: float,
|
|
100
|
+
) -> FrontendConfig:
|
|
101
|
+
return FrontendConfig(
|
|
102
|
+
name="logmel",
|
|
103
|
+
stft=STFTConfig(
|
|
104
|
+
sample_rate=sample_rate,
|
|
105
|
+
n_fft=n_fft,
|
|
106
|
+
win_length=win_length,
|
|
107
|
+
hop_length=hop_length,
|
|
108
|
+
center=True,
|
|
109
|
+
power=2.0,
|
|
110
|
+
),
|
|
111
|
+
mel=MelConfig(
|
|
112
|
+
n_mels=n_mels,
|
|
113
|
+
f_min=0.0,
|
|
114
|
+
f_max=f_max,
|
|
115
|
+
mel_scale="htk",
|
|
116
|
+
mel_norm="none",
|
|
117
|
+
filterbank_impl="kaldi_compatible",
|
|
118
|
+
),
|
|
119
|
+
log=LogCompressionConfig(kind="log"),
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def _audio_default_16k_waveform() -> AudioPreset:
|
|
124
|
+
return AudioPreset(
|
|
125
|
+
name="audio_default_16k_waveform",
|
|
126
|
+
input_duration=1.0,
|
|
127
|
+
target_sample_rate=16000,
|
|
128
|
+
preprocess=_preprocess(16000),
|
|
129
|
+
segment=_segment(1.0),
|
|
130
|
+
frontend=FrontendConfig(name="raw_waveform"),
|
|
131
|
+
label_transform=_label("index"),
|
|
132
|
+
layout="bt",
|
|
133
|
+
metadata={
|
|
134
|
+
"preset_version": 1,
|
|
135
|
+
"model_family": "generic",
|
|
136
|
+
"frontend_contract": "raw-waveform-16k-v1",
|
|
137
|
+
},
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def _audio_default_32k_logmel(n_mels: int) -> AudioPreset:
|
|
142
|
+
name = f"audio_default_32k_logmel{n_mels}"
|
|
143
|
+
return AudioPreset(
|
|
144
|
+
name=name,
|
|
145
|
+
input_duration=1.0,
|
|
146
|
+
target_sample_rate=32000,
|
|
147
|
+
preprocess=_preprocess(32000),
|
|
148
|
+
segment=_segment(1.0),
|
|
149
|
+
frontend=_logmel_frontend(
|
|
150
|
+
sample_rate=32000,
|
|
151
|
+
n_fft=1024,
|
|
152
|
+
win_length=800,
|
|
153
|
+
hop_length=320,
|
|
154
|
+
n_mels=n_mels,
|
|
155
|
+
f_max=15000.0,
|
|
156
|
+
),
|
|
157
|
+
label_transform=_label("index"),
|
|
158
|
+
layout="btf",
|
|
159
|
+
metadata={
|
|
160
|
+
"preset_version": 1,
|
|
161
|
+
"model_family": "generic",
|
|
162
|
+
"frontend_contract": f"logmel-32k-{n_mels}-v1",
|
|
163
|
+
},
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def _audioset_logmel(
|
|
168
|
+
*,
|
|
169
|
+
name: str,
|
|
170
|
+
sample_rate: int,
|
|
171
|
+
n_fft: int,
|
|
172
|
+
win_length: int,
|
|
173
|
+
hop_length: int,
|
|
174
|
+
n_mels: int,
|
|
175
|
+
f_max: float,
|
|
176
|
+
) -> AudioPreset:
|
|
177
|
+
return AudioPreset(
|
|
178
|
+
name=name,
|
|
179
|
+
input_duration=10.0,
|
|
180
|
+
target_sample_rate=sample_rate,
|
|
181
|
+
preprocess=_preprocess(sample_rate),
|
|
182
|
+
segment=_segment(10.0),
|
|
183
|
+
frontend=_logmel_frontend(
|
|
184
|
+
sample_rate=sample_rate,
|
|
185
|
+
n_fft=n_fft,
|
|
186
|
+
win_length=win_length,
|
|
187
|
+
hop_length=hop_length,
|
|
188
|
+
n_mels=n_mels,
|
|
189
|
+
f_max=f_max,
|
|
190
|
+
),
|
|
191
|
+
label_transform=_label("multi_hot", 527),
|
|
192
|
+
layout="btf",
|
|
193
|
+
metadata={
|
|
194
|
+
"preset_version": 1,
|
|
195
|
+
"model_family": "generic",
|
|
196
|
+
"frontend_contract": f"audioset-logmel-{sample_rate}-{n_mels}-v1",
|
|
197
|
+
},
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def _register_builtin_presets() -> None:
|
|
202
|
+
for preset in (
|
|
203
|
+
_audio_default_16k_waveform(),
|
|
204
|
+
_audio_default_32k_logmel(64),
|
|
205
|
+
_audio_default_32k_logmel(128),
|
|
206
|
+
_audioset_logmel(
|
|
207
|
+
name="audioset_32k_10s_logmel128",
|
|
208
|
+
sample_rate=32000,
|
|
209
|
+
n_fft=1024,
|
|
210
|
+
win_length=800,
|
|
211
|
+
hop_length=320,
|
|
212
|
+
n_mels=128,
|
|
213
|
+
f_max=15000.0,
|
|
214
|
+
),
|
|
215
|
+
_audioset_logmel(
|
|
216
|
+
name="audioset_32k_10s_logmel64",
|
|
217
|
+
sample_rate=32000,
|
|
218
|
+
n_fft=1024,
|
|
219
|
+
win_length=800,
|
|
220
|
+
hop_length=320,
|
|
221
|
+
n_mels=64,
|
|
222
|
+
f_max=15000.0,
|
|
223
|
+
),
|
|
224
|
+
_audioset_logmel(
|
|
225
|
+
name="audioset_16k_10s_logmel64",
|
|
226
|
+
sample_rate=16000,
|
|
227
|
+
n_fft=400,
|
|
228
|
+
win_length=400,
|
|
229
|
+
hop_length=160,
|
|
230
|
+
n_mels=64,
|
|
231
|
+
f_max=8000.0,
|
|
232
|
+
),
|
|
233
|
+
efficientat_32k_10s_logmel128(),
|
|
234
|
+
dymn_32k_10s_logmel128(),
|
|
235
|
+
dcase2025_task1_efficientat_32k_1s(),
|
|
236
|
+
dcase2025_task1_dymn_32k_1s(),
|
|
237
|
+
dcase2025_task1_efficientat_32k_1s_zero_pad_to_10s(),
|
|
238
|
+
dcase2025_task1_efficientat_32k_1s_repeat_to_10s(),
|
|
239
|
+
passt_32k_10s_logmel128(),
|
|
240
|
+
dcase2025_task1_passt_32k_1s(),
|
|
241
|
+
dcase2025_task1_passt_32k_1s_zero_pad_to_10s(),
|
|
242
|
+
dcase2025_task1_passt_32k_1s_repeat_to_10s(),
|
|
243
|
+
ced_tiny_16k_logmel64(),
|
|
244
|
+
ced_mini_16k_logmel64(),
|
|
245
|
+
ced_small_16k_logmel64(),
|
|
246
|
+
ced_base_16k_logmel64(),
|
|
247
|
+
dcase2025_task1_ced_16k_1s(),
|
|
248
|
+
panns_cnn14_32k_10s_logmel64(),
|
|
249
|
+
panns_cnn14_16k_10s_logmel64(),
|
|
250
|
+
ast_audioset_16k_10s_fbank128(),
|
|
251
|
+
ast_esc50_16k_5s_fbank128(),
|
|
252
|
+
ast_speechcommands_16k_1s_fbank128(),
|
|
253
|
+
):
|
|
254
|
+
register_preset(preset.name, preset)
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
_register_builtin_presets()
|