mirror of
https://github.com/macaodha/batdetect2.git
synced 2025-06-29 14:41:58 +02:00
Expose preprocessing functions
This commit is contained in:
parent
e383a33cbf
commit
bfa6049adc
@ -3,7 +3,6 @@
|
||||
from typing import Optional
|
||||
|
||||
import xarray as xr
|
||||
from pydantic import BaseModel, Field
|
||||
from soundevent import data
|
||||
|
||||
from batdetect2.preprocess.audio import (
|
||||
@ -11,41 +10,39 @@ from batdetect2.preprocess.audio import (
|
||||
ResampleConfig,
|
||||
load_clip_audio,
|
||||
)
|
||||
from batdetect2.preprocess.config import (
|
||||
PreprocessingConfig,
|
||||
load_preprocessing_config,
|
||||
)
|
||||
from batdetect2.preprocess.spectrogram import (
|
||||
AmplitudeScaleConfig,
|
||||
STFTConfig,
|
||||
FrequencyConfig,
|
||||
LogScaleConfig,
|
||||
PcenScaleConfig,
|
||||
Scales,
|
||||
SpecSizeConfig,
|
||||
SpectrogramConfig,
|
||||
STFTConfig,
|
||||
compute_spectrogram,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"AudioConfig",
|
||||
"ResampleConfig",
|
||||
"SpectrogramConfig",
|
||||
"STFTConfig",
|
||||
"FrequencyConfig",
|
||||
"PcenScaleConfig",
|
||||
"LogScaleConfig",
|
||||
"AmplitudeScaleConfig",
|
||||
"AudioConfig",
|
||||
"FrequencyConfig",
|
||||
"LogScaleConfig",
|
||||
"PcenScaleConfig",
|
||||
"PreprocessingConfig",
|
||||
"ResampleConfig",
|
||||
"STFTConfig",
|
||||
"Scales",
|
||||
"SpecSizeConfig",
|
||||
"PreprocessingConfig",
|
||||
"SpectrogramConfig",
|
||||
"load_preprocessing_config",
|
||||
"preprocess_audio_clip",
|
||||
]
|
||||
|
||||
|
||||
class PreprocessingConfig(BaseModel):
|
||||
"""Configuration for preprocessing data."""
|
||||
|
||||
audio: AudioConfig = Field(default_factory=AudioConfig)
|
||||
spectrogram: SpectrogramConfig = Field(default_factory=SpectrogramConfig)
|
||||
|
||||
|
||||
def preprocess_audio_clip(
|
||||
clip: data.Clip,
|
||||
config: Optional[PreprocessingConfig] = None,
|
||||
|
31
batdetect2/preprocess/config.py
Normal file
31
batdetect2/preprocess/config.py
Normal file
@ -0,0 +1,31 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import Field
|
||||
from soundevent.data import PathLike
|
||||
|
||||
from batdetect2.configs import BaseConfig, load_config
|
||||
from batdetect2.preprocess.audio import (
|
||||
AudioConfig,
|
||||
)
|
||||
from batdetect2.preprocess.spectrogram import (
|
||||
SpectrogramConfig,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"PreprocessingConfig",
|
||||
"load_preprocessing_config",
|
||||
]
|
||||
|
||||
|
||||
class PreprocessingConfig(BaseConfig):
|
||||
"""Configuration for preprocessing data."""
|
||||
|
||||
audio: AudioConfig = Field(default_factory=AudioConfig)
|
||||
spectrogram: SpectrogramConfig = Field(default_factory=SpectrogramConfig)
|
||||
|
||||
|
||||
def load_preprocessing_config(
|
||||
path: PathLike,
|
||||
field: Optional[str] = None,
|
||||
) -> PreprocessingConfig:
|
||||
return load_config(path, schema=PreprocessingConfig, field=field)
|
Loading…
Reference in New Issue
Block a user