Audio
AudioAssetParams
AudioAsset
Bases: BaseAsset[AudioAssetParams]
Represents an Audio asset with various properties.
type
class-attribute
instance-attribute
type: Literal['audio'] = 'audio'
The type of the asset. Defaults to "audio".
params
class-attribute
instance-attribute
params: AudioAssetParams = Field(
default_factory=AudioAssetParams
)
The parameters for the asset.
from_data
classmethod
from_data(
data: str | bytes,
*,
path: PathLike | None = None,
metadata: dict | None = None,
mime_type: str | None = None,
**kwargs: Any
) -> Self
Creates an audio asset from data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
str | bytes
|
The data of the assets. |
required |
path |
PathLike | None
|
The path to the file. |
None
|
metadata |
dict | None
|
The metadata of the assets. |
None
|
mime_type |
str | None
|
The MIME type of the assets. |
None
|
kwargs |
Any
|
Additional keyword arguments to the constructor. |
{}
|
Returns:
Type | Description |
---|---|
Self
|
The assets. |
Source code in src/mosaico/assets/audio.py
from_path
classmethod
from_path(
path: PathLike,
*,
encoding: str = "utf-8",
mime_type: str | None = None,
guess_mime_type: bool = True,
metadata: dict | None = None,
**kwargs: Any
) -> Self
Creates an audio asset from a file path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
PathLike
|
The path to the file. |
required |
encoding |
str
|
The encoding of the file. |
'utf-8'
|
metadata |
dict | None
|
The metadata of the assets. |
None
|
mime_type |
str | None
|
The MIME type of the assets. |
None
|
guess_mime_type |
bool
|
Whether to guess the MIME type. |
True
|
kwargs |
Any
|
Additional keyword arguments to the constructor. |
{}
|
Returns:
Type | Description |
---|---|
Self
|
The assets. |
Source code in src/mosaico/assets/audio.py
slice
slice(start_time: float, end_time: float) -> AudioAsset
Slices the audio asset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_time |
float
|
The start time in seconds. |
required |
end_time |
float
|
The end time in seconds. |
required |
Returns:
Type | Description |
---|---|
AudioAsset
|
The sliced audio asset. |