2026-01-21 00:25:25 +08:00
|
|
|
import numpy as np
|
|
|
|
|
from vllm.assets.video import VideoAsset
|
2026-04-10 14:11:31 -04:00
|
|
|
from vllm.multimodal.media.audio import load_audio
|
2026-01-21 00:25:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def extract_video_audio(path: str = None, sampling_rate: int = 16000) -> np.ndarray:
|
|
|
|
|
"""This function extracts the audio from a video file path and returns the audio as a numpy array.
|
|
|
|
|
Args:
|
|
|
|
|
path: The path to the video file.
|
|
|
|
|
Returns:
|
|
|
|
|
The audio as a numpy array.
|
|
|
|
|
"""
|
|
|
|
|
if not path:
|
|
|
|
|
path = VideoAsset(name="baby_reading").video_path
|
2026-04-10 14:11:31 -04:00
|
|
|
audio_signal, sr = load_audio(path, sr=sampling_rate)
|
2026-01-21 00:25:25 +08:00
|
|
|
return audio_signal
|