Utilities#
audioclass.utils
#
Utility functions for audioclass.
This module provides various helper functions for working with audio data and models.
Functions#
flat_sigmoid(x, sensitivity=1, vmin=-15, vmax=15)
#
Apply a flattened sigmoid function to an array.
This function applies a sigmoid function to each element of the input array, but with a flattened shape to prevent extreme values. The output values are clipped between 0 and 1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
ndarray
|
The input array. |
required |
sensitivity |
float
|
The sensitivity of the sigmoid function. Defaults to 1. |
1
|
vmin |
float
|
The minimum value to clip the input to. Defaults to -15. |
-15
|
vmax |
float
|
The maximum value to clip the input to. Defaults to 15. |
15
|
Returns:
Type | Description |
---|---|
ndarray
|
The output array with the same shape as the input. |
load_artifact(path, directory=None, download=True)
#
Load an artifact from a local path or a URL.
If the path is a URL, the artifact is downloaded and cached in a local directory. If the artifact is already cached, it is loaded from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Union[Path, str]
|
The path to the artifact, either a local path or a URL. |
required |
directory |
Optional[Path]
|
The directory to cache the artifact in. If not provided, a default cache directory is used. |
None
|
download |
bool
|
Whether to download the artifact if it is not found in the cache. Defaults to True. |
True
|
Returns:
Type | Description |
---|---|
Path
|
The path to the loaded artifact. |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If the artifact is not found and |