[Refactor] Remove resampy dependency (#2891)

Signed-off-by: Nick Cao <ncao@redhat.com>
This commit is contained in:
Nick Cao authored and GitHub committed 2026-04-18 03:20:36 +00:00
1 parent 4f71f7309e
commit d2c23d7bd0
4 files changed
+12 -10

No files matched your search

@@ -5,7 +5,7 @@ speaker encoder from a Qwen3-TTS checkpoint, then interpolates between them
using SLERP and sends the result to the /v1/audio/speech API.
Requirements:
pip install torch resampy soundfile numpy httpx
pip install torch soundfile numpy httpx
Examples:
# Extract and save an embedding
@@ -143,11 +143,12 @@ def _load_speaker_encoder_weights(encoder: torch.nn.Module, model_path: str) ->
def compute_mel_spectrogram(audio: np.ndarray, sr: int = 24000) -> torch.Tensor:
"""Compute 128-bin mel spectrogram matching Qwen3-TTS's extraction pipeline."""
from vllm.multimodal.audio import resample_audio_resampy
from vllm.multimodal.audio import AudioResampler
# Resample to 24kHz if needed
if sr != 24000:
audio = resample_audio_resampy(audio.astype(np.float32), orig_sr=sr, target_sr=24000)
resampler = AudioResampler(target_sr=24000)
audio = resampler.resample(audio.astype(np.float32), orig_sr=sr)
y = torch.from_numpy(audio).unsqueeze(0).float()