Audio¶
Qualified name: algan.animation\_timeline.animation\_contexts.Audio
- class Audio(source, *, wait_at_end=0.0, **kwargs)[source]¶
Bases:
AnimationContextPlay a sound, and fit the block’s animations to its length.
The context’s runtime is taken from the audio, so whatever you animate inside is stretched or squeezed to finish with the sound. That inversion is the point: you describe what should happen while a clip plays, rather than timing the clip against the animation.
- Parameters:
source (str) – Path to an audio file, or an already-loaded moviepy audio clip.
wait_at_end (float) – Extra seconds to hold after the audio finishes, before the block ends. Defaults to
0.**kwargs (Any) – Passed to
AnimationContext. Noteruntimeis set from the audio and should not be passed.
Examples
with Audio("whoosh.wav"): square.move(RIGHT * 5) # takes exactly as long as the clip
See also
SpeechThe same, driven by a line of narration transcript.
Methods
Attributes
animation_managerchild_contextscombine_easingcomposed_easingcurrent_timeWhere the authoring cursor sits within this context, in seconds.
easingend_timeThe furthest time anything recorded in this context reaches, in seconds.
equalize_runtimesfinishedkwargslag_rationew_animationnew_mobsprev_contextpriority_levelrecord_attr_modificationsrecord_funcsruntimeruntime_per_partspawn_at_end