[Bugfix] treewide: drop references to librosa (#2996)
Signed-off-by: Nick Cao <ncao@redhat.com>
This commit is contained in:
1 parent
25b451a552
commit
339a6da28c
4 files changed
+16
-12
No files matched your search
@@ -6,7 +6,6 @@ import os
|
|||||||
import time
|
import time
|
||||||
from typing import NamedTuple
|
from typing import NamedTuple
|
||||||
|
|
||||||
import librosa
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import vllm
|
import vllm
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
@@ -16,6 +15,7 @@ from vllm.assets.audio import AudioAsset
|
|||||||
from vllm.assets.image import ImageAsset
|
from vllm.assets.image import ImageAsset
|
||||||
from vllm.assets.video import VideoAsset, video_to_ndarrays
|
from vllm.assets.video import VideoAsset, video_to_ndarrays
|
||||||
from vllm.multimodal.image import convert_image_mode
|
from vllm.multimodal.image import convert_image_mode
|
||||||
|
from vllm.multimodal.media.audio import load_audio
|
||||||
from vllm.utils.argparse_utils import FlexibleArgumentParser
|
from vllm.utils.argparse_utils import FlexibleArgumentParser
|
||||||
|
|
||||||
import vllm_omni
|
import vllm_omni
|
||||||
@@ -91,7 +91,7 @@ def get_audio_query(
|
|||||||
if audio_path:
|
if audio_path:
|
||||||
if not os.path.exists(audio_path):
|
if not os.path.exists(audio_path):
|
||||||
raise FileNotFoundError(f"Audio file not found: {audio_path}")
|
raise FileNotFoundError(f"Audio file not found: {audio_path}")
|
||||||
audio_signal, sr = librosa.load(audio_path, sr=sampling_rate)
|
audio_signal, sr = load_audio(audio_path, sr=sampling_rate)
|
||||||
audio_data = (audio_signal.astype(np.float32), sr)
|
audio_data = (audio_signal.astype(np.float32), sr)
|
||||||
else:
|
else:
|
||||||
audio_data = AudioAsset("mary_had_lamb").audio_and_sample_rate
|
audio_data = AudioAsset("mary_had_lamb").audio_and_sample_rate
|
||||||
@@ -172,7 +172,7 @@ def get_mixed_modalities_query(
|
|||||||
if audio_path:
|
if audio_path:
|
||||||
if not os.path.exists(audio_path):
|
if not os.path.exists(audio_path):
|
||||||
raise FileNotFoundError(f"Audio file not found: {audio_path}")
|
raise FileNotFoundError(f"Audio file not found: {audio_path}")
|
||||||
sig, sr = librosa.load(audio_path, sr=sampling_rate)
|
sig, sr = load_audio(audio_path, sr=sampling_rate)
|
||||||
audio_data = (sig.astype(np.float32), sr)
|
audio_data = (sig.astype(np.float32), sr)
|
||||||
else:
|
else:
|
||||||
audio_data = AudioAsset("mary_had_lamb").audio_and_sample_rate
|
audio_data = AudioAsset("mary_had_lamb").audio_and_sample_rate
|
||||||
|
|||||||
+10
-6
@@ -127,12 +127,13 @@ exclude = [
|
|||||||
|
|
||||||
[tool.ruff.lint]
|
[tool.ruff.lint]
|
||||||
select = [
|
select = [
|
||||||
"E", # pycodestyle errors
|
"E", # pycodestyle errors
|
||||||
"W", # pycodestyle warnings
|
"W", # pycodestyle warnings
|
||||||
"F", # pyflakes
|
"F", # pyflakes
|
||||||
"I", # isort (handled separately, but included for compatibility)
|
"I", # isort (handled separately, but included for compatibility)
|
||||||
"N", # pep8-naming
|
"N", # pep8-naming
|
||||||
"UP", # pyupgrade
|
"UP", # pyupgrade
|
||||||
|
"TID251", # flake8-tidy-imports.banned-api
|
||||||
]
|
]
|
||||||
ignore = [
|
ignore = [
|
||||||
"E203", # whitespace before ':' (conflicts with black)
|
"E203", # whitespace before ':' (conflicts with black)
|
||||||
@@ -147,6 +148,9 @@ ignore = [
|
|||||||
"examples/**" = ["E501"] # Allow long lines in examples
|
"examples/**" = ["E501"] # Allow long lines in examples
|
||||||
"tests/**" = ["E501"] # Allow long lines in tests
|
"tests/**" = ["E501"] # Allow long lines in tests
|
||||||
|
|
||||||
|
[tool.ruff.lint.flake8-tidy-imports.banned-api]
|
||||||
|
"librosa".msg = "The librosa module is banned, use vllm.multimodal helpers instead"
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
python_version = "3.12, 3.13"
|
python_version = "3.12, 3.13"
|
||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ from __future__ import annotations
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
torch = pytest.importorskip("torch")
|
torch = pytest.importorskip("torch")
|
||||||
pytest.importorskip("librosa")
|
|
||||||
|
|
||||||
from vllm_omni.model_executor.models.voxcpm2.voxcpm2_talker import ( # noqa: E402
|
from vllm_omni.model_executor.models.voxcpm2.voxcpm2_talker import ( # noqa: E402
|
||||||
VoxCPM2TalkerForConditionalGeneration,
|
VoxCPM2TalkerForConditionalGeneration,
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import time
|
|||||||
from collections.abc import Iterable
|
from collections.abc import Iterable
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import librosa
|
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
from vllm.config import VllmConfig
|
from vllm.config import VllmConfig
|
||||||
@@ -30,6 +29,7 @@ from vllm.model_executor.models.utils import (
|
|||||||
WeightsMapper,
|
WeightsMapper,
|
||||||
maybe_prefix,
|
maybe_prefix,
|
||||||
)
|
)
|
||||||
|
from vllm.multimodal.audio import AudioResampler
|
||||||
from vllm.sequence import IntermediateTensors
|
from vllm.sequence import IntermediateTensors
|
||||||
|
|
||||||
from vllm_omni.model_executor.models.output_templates import OmniOutput
|
from vllm_omni.model_executor.models.output_templates import OmniOutput
|
||||||
@@ -145,7 +145,8 @@ def _encode_raw_audio(
|
|||||||
encode_sr = tts._encode_sample_rate
|
encode_sr = tts._encode_sample_rate
|
||||||
if sr != encode_sr:
|
if sr != encode_sr:
|
||||||
audio_np = audio.squeeze(0).numpy()
|
audio_np = audio.squeeze(0).numpy()
|
||||||
audio_np = librosa.resample(audio_np, orig_sr=sr, target_sr=encode_sr)
|
resampler = AudioResampler(target_sr=encode_sr)
|
||||||
|
audio_np = resampler.resample(audio_np, orig_sr=sr)
|
||||||
audio = torch.from_numpy(audio_np).unsqueeze(0)
|
audio = torch.from_numpy(audio_np).unsqueeze(0)
|
||||||
|
|
||||||
patch_len = tts.patch_size * tts.chunk_size
|
patch_len = tts.patch_size * tts.chunk_size
|
||||||
|
|||||||
Reference in new issue
Block a user