nvidia.dali.fn.audio_resample

nvidia.dali.fn.audio_resample(__input, /, *, bytes_per_sample_hint=[0], dtype=None, in_rate=None, out_length=None, out_rate=None, preserve=False, quality=50.0, scale=None, seed=-1, device=None, name=None)

Resamples an audio signal.

The resampling is achieved by applying a sinc filter with Hann window with an extent controlled by the quality argument.

The resampling ratio can be specified directly or as a ratio of target to source sampling rate, or calculated from the ratio of the requested output length to the input length.

Supported backends
  • ‘cpu’

  • ‘gpu’

Parameters:

__input (TensorList) – Input to the operator.

Keyword Arguments:
  • bytes_per_sample_hint (int or list of int, optional, default = [0]) –

    Output size hint, in bytes per sample.

    If specified, the operator’s outputs residing in GPU or page-locked host memory will be preallocated to accommodate a batch of samples of this size.

  • dtype (nvidia.dali.types.DALIDataType, optional) –

    The ouput type.

    If not specified, the output type is the same as the input type. When the type is changed, the values are normalized to fill the dynamic range of the target data type. When converting floating point inputs to integer types, the input values are assumed to be in -1..1 range. When converting between signed and unsigned types, 0 translates to half-range of the unsigned type. Example:

    float -> uint8
    -1.0  -> 0
    0     -> 128
    1.0   -> 255
    
    uint8 -> int16
    0     -> -32767
    127   -> -128
    128   ->  128
    255   ->  32767
    
    uint16 -> float
    0      -> -1
    32767  -> -0.000015
    32768  ->  0.000015
    65535  ->  1
    

  • in_rate (float or TensorList of float, optional) –

    Input sampling rate.

    The sampling rate of the input sample. This parameter must be specified together with out_rate. The value is relative to out_rate and doesn’t need to use any specific unit as long as the units of input and output rates match.

    The in_rate and out_rate parameters cannot be specified together with scale or out_length.

  • out_length (int or TensorList of int, optional) –

    The requested output length, in samples.

    The scaling factor is the ratio of this output length to the input length. This parameter cannot be specified together with in_rate, out_rate or scale.

  • out_rate (float or TensorList of float, optional) –

    Output sampling rate.

    The requested output sampling rate. This parameter must be specified together with in_rate. The value is relative to in_rate and doesn’t need to use any specific unit as long as the units of input and output rates match.

    The in_rate and out_rate parameters cannot be specified together with scale or out_length.

  • preserve (bool, optional, default = False) – Prevents the operator from being removed from the graph even if its outputs are not used.

  • quality (float, optional, default = 50.0) –

    Resampling quality, where 0 is the lowest, and 100 is the highest.

    0 gives 3 lobes of the sinc filter, 50 gives 16 lobes, and 100 gives 64 lobes.

  • scale (float or TensorList of float, optional) –

    The scaling factor.

    The scaling factor is the ratio of the target sampling rate to source sampling rate. For example, a scale=2 will produce an output with twice as many samples as the input.

    This parameter cannot be specified together with in_rate and out_rate or out_length.

  • seed (int, optional, default = -1) –

    Random seed.

    If not provided, it will be populated based on the global seed of the pipeline.