wed.utils.audio_utils module¶
- wed.utils.audio_utils.synthesize_audio(video_path: str, audio_path: str, out_path: Optional[str] = None, start: int = 0, end: int = - 1, volume: int = 0, offset: str = '00:00:00', open: bool = True, delete_intermidiates: bool = False, logger: Optional[logging.Logger] = None) → str[source]¶
Use
ffmpeg
directly ormoviepy
to synthesize audio (@audio_path
) to video (@video_path
)- Parameters
video_path (str) – The path to video fiile.
audio_path (str) – The path to audio (video) fiile.
out_path (Optional[str], optional) – The path to the created video (with audio) file. Defaults to
None
.offset (str, optional) – Offset until the voice starts. Defaults to
"00:00:00"
.open (bool, optional) – Whether to open the created video or not. Defaults to
True
.delete_silence (bool, optional) – Whether to delete the silence video (
video_path
) or not. Defaults toFalse
.
- Returns
The path to the created video (with audio) file.
- Return type
str
Examples
>>> from wed.utils import synthesize_audio >>> # Prepare Audio file (.mp3) >>> synthesize_audio(audio_path="sound.mp3", video_path="no_sound.mp4") >>> # Prepare Video with Audio file (.mp4) >>> synthesize_audio(audio_path="sound.mp4", video_path="no_sound.mp4")
- wed.utils.audio_utils.overlay_audio(base_media_path: str, overlay_media_path: str, out_path: Optional[str] = None, position: int = 0) → str[source]¶
Overlay audio at
overlay_media_path
on audio atbase_media_path
.- Parameters
base_media_path (str) – The path to media file (contains audio) to be overlayed.
overlay_media_path (str) – The path to media file (contains audio) to overlay.
out_path (Optional[str], optional) – Path to the created audio file. Defaults to
None
.position (int, optional) – The position (
[ms]
) to start overlaying the provided segment in to this one. Defaults to0
.
- Returns
Path to the created audio file.
- Return type
str