nussl/datasets/base_dataset.py
def _setup_audio_signal(self, audio_signal):
        """
        You will want every item from a dataset to be uniform in sample rate, STFT
        parameters, and number of channels. This function takes an audio signal 
        object loaded by the dataset and uses it to set the sample rate, STFT parameters,
        and the number of channels. If ``self.sample_rate``, ``self.stft_params``, and
        ``self.num_channels`` are set at construction time of the dataset, then the
        opposite happens - attributes of the AudioSignal object are set to the desired
        values.
        
        Args:
            audio_signal (AudioSignal): AudioSignal object to query to set the parameters
              of this dataset or to set the parameters of, according to what is in the 
              dataset.
        """
        if self.sample_rate and self.sample_rate != audio_signal.sample_rate:
            if self.strict_sample_rate:
                raise DataSetException(
                    f"All audio files should have been the same sample rate already " 
                    f"because self.strict_sample_rate = True. Please resample or "
                    f"turn set self.strict_sample_rate = False"
                )
            audio_signal.resample(self.sample_rate)  
        else:
            self.sample_rate = audio_signal.sample_rate

        # set audio signal attributes to requested values, if they exist
        if self.stft_params:
            audio_signal.stft_params = self.stft_params
        else:
            self.stft_params = audio_signal.stft_params

        if self.num_channels:
            if audio_signal.num_channels > self.num_channels:
                # pick the first ``self.num_channels`` channels 
                audio_signal.audio_data = audio_signal.audio_data[:self.num_channels]
            elif audio_signal.num_channels < self.num_channels:
                warnings.warn(
                    f"AudioSignal had {audio_signal.num_channels} channels "
                    f"but self.num_channels = {self.num_channels}. Unsure "
                    f"of what to do, so warning. You might want to make sure "
                    f"your dataset is uniform!"
                )
        else:
            self.num_channels = audio_signal.num_channels

        You will want every item from a dataset to be uniform in sample rate, STFT
        parameters, and number of channels. This function takes an audio signal 
        object loaded by the dataset and uses it to set the sample rate, STFT parameters,
        and the number of channels. If ``self.sample_rate``, ``self.stft_params``, and
        ``self.num_channels`` are set at construction time of the dataset, then the
        opposite happens - attributes of the AudioSignal object are set to the desired
        values.
        
        Args:
            audio_signal (AudioSignal): AudioSignal object to query to set the parameters
              of this dataset or to set the parameters of, according to what is in the 
              dataset.
        
You will want every item from a dataset to be uniform in sample rate, STFT
parameters, and number of channels. This function takes an audio signal
object loaded by the dataset and uses it to set the sample rate, STFT parameters,
and the number of channels.
You will want every item from a dataset to be uniform in sample rate STFT parameters and number of channels . This function takes an audio signal object loaded by the dataset and uses it to set the sample rate STFT parameters and the number of channels .
def _setup_audio_signal(self, audio_signal):
        if self.sample_rate and self.sample_rate != audio_signal.sample_rate:
            if self.strict_sample_rate:
                raise DataSetException(
                    f"All audio files should have been the same sample rate already " 
                    f"because self.strict_sample_rate = True. Please resample or "
                    f"turn set self.strict_sample_rate = False"
                )
            audio_signal.resample(self.sample_rate)  
        else:
            self.sample_rate = audio_signal.sample_rate
        if self.stft_params:
            audio_signal.stft_params = self.stft_params
        else:
            self.stft_params = audio_signal.stft_params
        if self.num_channels:
            if audio_signal.num_channels > self.num_channels:
                audio_signal.audio_data = audio_signal.audio_data[:self.num_channels]
            elif audio_signal.num_channels < self.num_channels:
                warnings.warn(
                    f"AudioSignal had {audio_signal.num_channels} channels "
                    f"but self.num_channels = {self.num_channels}. Unsure "
                    f"of what to do, so warning. You might want to make sure "
                    f"your dataset is uniform!"
                )
        else:
            self.num_channels = audio_signal.num_channels
def _setup_audio_signal ( self , audio_signal ) : if self . sample_rate and self . sample_rate != audio_signal . sample_rate : if self . strict_sample_rate : raise DataSetException ( f"All audio files should have been the same sample rate already " f"because self.strict_sample_rate = True. Please resample or " f"turn set self.strict_sample_rate = False" ) audio_signal . resample ( self . sample_rate ) else : self . sample_rate = audio_signal . sample_rate if self . stft_params : audio_signal . stft_params = self . stft_params else : self . stft_params = audio_signal . stft_params if self . num_channels : if audio_signal . num_channels > self . num_channels : audio_signal . audio_data = audio_signal . audio_data [ : self . num_channels ] elif audio_signal . num_channels < self . num_channels : warnings . warn ( f"AudioSignal had {audio_signal.num_channels} channels " f"but self.num_channels = {self.num_channels}. Unsure " f"of what to do, so warning. You might want to make sure " f"your dataset is uniform!" ) else : self . num_channels = audio_signal . num_channels
You will want every item from a dataset to be uniform in sample rate, STFT
parameters, and number of channels.
You will want every item from a dataset to be uniform in sample rate STFT parameters and number of channels .
"""
        You will want every item from a dataset to be uniform in sample rate, STFT
        parameters, and number of channels. This function takes an audio signal 
        object loaded by the dataset and uses it to set the sample rate, STFT parameters,
        and the number of channels. If ``self.sample_rate``, ``self.stft_params``, and
        ``self.num_channels`` are set at construction time of the dataset, then the
        opposite happens - attributes of the AudioSignal object are set to the desired
        values.
        
        Args:
            audio_signal (AudioSignal): AudioSignal object to query to set the parameters
              of this dataset or to set the parameters of, according to what is in the 
              dataset.
        """ # set audio signal attributes to requested values, if they exist # pick the first ``self.num_channels`` channels 
self
audio_signal
AudioSignal object to query to set the parameters
of this dataset or to set the parameters of, according to what is in the
dataset.
AudioSignal object to query to set the parameters of this dataset or to set the parameters of according to what is in the dataset .