espnet2.layers.augmentation.bandwidth_limitation
Less than 1 minute
espnet2.layers.augmentation.bandwidth_limitation
espnet2.layers.augmentation.bandwidth_limitation(waveform, sample_rate: int, res_type='random')
Apply the bandwidth limitation distortion to the input signal.
This function reduces the effective sampling rate of the input waveform by randomly selecting from available lower sampling rates and resampling the signal accordingly. It is particularly useful for simulating bandwidth-limited conditions in audio processing.
- Parameters:
waveform (np.ndarray) – A single speech sample (…, Time).
sample_rate (int) – Input sampling rate in Hz.
res_type (str) –
Resampling method. Defaults to “random”. Valid options include:
- ”kaiser_best”
- ”kaiser_fast”
- ”scipy”
- ”polyphase”
- Returns: Bandwidth-limited speech sample (…, Time).
- Return type: ret (np.ndarray)
Examples
>>> import numpy as np
>>> sample_rate = 16000
>>> waveform = np.random.rand(sample_rate) # Example waveform
>>> limited_waveform = bandwidth_limitation(waveform, sample_rate)
NOTE
If no valid lower sampling rates are found, the original waveform will be returned without any changes.
- Raises:ValueError – If the input waveform is not a 1D or 2D numpy array.