
    qi                     :    d Z ddlZddlZddlmZ  G d de      Zy)zResampy-based audio resampler implementation.

This module provides an audio resampler that uses the resampy library
for high-quality audio sample rate conversion.
    N)BaseAudioResamplerc                   .    e Zd ZdZd ZdedededefdZy)	ResampyResamplerzAudio resampler implementation using the resampy library.

    This resampler uses the resampy library's Kaiser windowing filter
    for high-quality audio resampling with good performance characteristics.
    c                      y)zInitialize the resampy resampler.

        Args:
            **kwargs: Additional keyword arguments (currently unused).
        N )selfkwargss     \/opt/pipecat/venv/lib/python3.12/site-packages/pipecat/audio/resamplers/resampy_resampler.py__init__zResampyResampler.__init__   s     	    audioin_rateout_ratereturnc                    K   ||k(  r|S t        j                  |t         j                        }t        j                  |||d      }|j                  t         j                        j                         }|S w)aH  Resample audio data using resampy library.

        Args:
            audio: Input audio data as raw bytes (16-bit signed integers).
            in_rate: Original sample rate in Hz.
            out_rate: Target sample rate in Hz.

        Returns:
            Resampled audio data as raw bytes (16-bit signed integers).
        )dtypekaiser_fast)filter)np
frombufferint16resampyresampleastypetobytes)r   r   r   r   
audio_dataresampled_audioresults          r
   r   zResampyResampler.resample"   sb      hL]]59
!**:wQ^_ ''199;s   A5A7N)__name__
__module____qualname____doc__r   bytesintr   r   r   r
   r   r      s-    E C 3 5 r   r   )r"   numpyr   r   -pipecat.audio.resamplers.base_audio_resamplerr   r   r   r   r
   <module>r'      s"      L) r   