Files
vllm-omni/vllm_omni/assets/video.py
T

16 lines
567 B
Python
Raw Normal View History

+13
2026-01-21 00:25:25 +08:00
import numpy as np
from vllm.assets.video import VideoAsset
from vllm.multimodal.media.audio import load_audio
+13
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
audio_signal, sr = load_audio(path, sr=sampling_rate)
+13
2026-01-21 00:25:25 +08:00
return audio_signal