movis.layer.media.Audio#

class movis.layer.media.Audio(audio_file: str | PathLike | ndarray)[source]#

Audio layer to encapsulate various formats of audio data.

Args:
audio_file:

the source of the audio data. It can be a file path (str or Path) or a numpy.ndarray with a shape of (2, N) and a sampling rate of 44100. If the audio data is a mono channel, it will be broadcasted to a stereo channel.

Methods

get_audio(start_time: float, end_time: float) ndarray | None[source]#

Get the audio data for the given time range.

Args:

start_time: the start time of the audio data. end_time: the end time of the audio data.

Returns:

The audio data for the given time range. If no audio data is found, None is returned.

get_key(time: float) int[source]#

Get the state index for the given time.

Note:

This method always returns a constant value because the audio data does not affect the image data.

Attributes

audio

The audio data with a shape of (2, N) with a sampling rate of 44100.

audio_file

The file path of the audio data.

duration

The duration of the audio data.