Signed-off-by: Nick Cao <ncao@redhat.com> Co-authored-by: Claude <noreply@anthropic.com>
17 lines
567 B
Python
17 lines
567 B
Python
import numpy as np
|
|
from vllm.assets.video import VideoAsset
|
|
from vllm.multimodal.media.audio import load_audio
|
|
|
|
|
|
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)
|
|
return audio_signal
|