chore(audio): deprecate ResampyResampler in favor of SOXR resamplers
Emits a DeprecationWarning on instantiation. ResampyResampler will be removed in Pipecat 2.0 along with the default resampy and numba dependencies.
This commit is contained in:
@@ -10,6 +10,8 @@ This module provides an audio resampler that uses the resampy library
|
|||||||
for high-quality audio sample rate conversion.
|
for high-quality audio sample rate conversion.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import warnings
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import resampy
|
import resampy
|
||||||
|
|
||||||
@@ -21,6 +23,11 @@ class ResampyResampler(BaseAudioResampler):
|
|||||||
|
|
||||||
This resampler uses the resampy library's Kaiser windowing filter
|
This resampler uses the resampy library's Kaiser windowing filter
|
||||||
for high-quality audio resampling with good performance characteristics.
|
for high-quality audio resampling with good performance characteristics.
|
||||||
|
|
||||||
|
.. deprecated:: 1.2.0
|
||||||
|
ResampyResampler is deprecated and will be removed in Pipecat 2.0.
|
||||||
|
Use SOXRAudioResampler, create_file_resampler(), or create_stream_resampler()
|
||||||
|
instead.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
@@ -29,7 +36,15 @@ class ResampyResampler(BaseAudioResampler):
|
|||||||
Args:
|
Args:
|
||||||
**kwargs: Additional keyword arguments (currently unused).
|
**kwargs: Additional keyword arguments (currently unused).
|
||||||
"""
|
"""
|
||||||
pass
|
with warnings.catch_warnings():
|
||||||
|
warnings.simplefilter("always")
|
||||||
|
warnings.warn(
|
||||||
|
"ResampyResampler is deprecated and will be removed in Pipecat 2.0. "
|
||||||
|
"Use SOXRAudioResampler, create_file_resampler(), or "
|
||||||
|
"create_stream_resampler() instead.",
|
||||||
|
DeprecationWarning,
|
||||||
|
stacklevel=2,
|
||||||
|
)
|
||||||
|
|
||||||
async def resample(self, audio: bytes, in_rate: int, out_rate: int) -> bytes:
|
async def resample(self, audio: bytes, in_rate: int, out_rate: int) -> bytes:
|
||||||
"""Resample audio data using resampy library.
|
"""Resample audio data using resampy library.
|
||||||
|
|||||||
17
tests/test_resampy_resampler.py
Normal file
17
tests/test_resampy_resampler.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2024-2026, Daily
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD 2-Clause License
|
||||||
|
#
|
||||||
|
|
||||||
|
"""Tests for the deprecated resampy resampler."""
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from pipecat.audio.resamplers.resampy_resampler import ResampyResampler
|
||||||
|
|
||||||
|
|
||||||
|
def test_resampy_resampler_emits_deprecation_warning():
|
||||||
|
"""Test that instantiating ResampyResampler emits a DeprecationWarning."""
|
||||||
|
with pytest.warns(DeprecationWarning, match="ResampyResampler is deprecated"):
|
||||||
|
ResampyResampler()
|
||||||
Reference in New Issue
Block a user