d5f74cc30a8f0a192d5ef8818c6d72c3707c4a97,nussl/audio_signal.py,AudioSignal,load_audio_from_file,#AudioSignal#Any#Any#Any#,287

Before Change


                Defaults to 0 seconds.

        
        if signal_length is not None and signal_starting_position >= signal_length:
            raise IndexError("signal_starting_position cannot be greater than signal_length!")

        try:
            with audioread.audio_open(os.path.realpath(input_file_path)) as input_file:
                self.sample_rate = input_file.samplerate
                file_length = input_file.duration
                n_ch = input_file.channels

            read_mono = True
            if n_ch != 1:
                read_mono = False

            audio_input, self.sample_rate = librosa.load(input_file_path,
                                                         sr=input_file.samplerate,
                                                         offset=0,
                                                         duration=file_length,
                                                         mono=read_mono)

            // Change from fixed point to floating point
            if not np.issubdtype(audio_input.dtype, float):
                audio_input = audio_input.astype("float") / (np.iinfo(audio_input.dtype).max + 1.0)

            self.audio_data = audio_input

        except Exception:
            raise IOError("Cannot read from file, {file}".format(file=input_file_path))

        self.path_to_input_file = input_file_path
        self._active_end = signal_length if signal_length is not None else self._audio_data.shape[self._LEN]
        self._active_start = signal_starting_position

    def load_audio_from_array(self, signal, sample_rate=constants.DEFAULT_SAMPLE_RATE):
        Loads an audio signal from a numpy array.

After Change


            with audioread.audio_open(os.path.realpath(input_file_path)) as input_file:
                file_length = input_file.duration

            if offset > file_length:
                raise ValueError("offset is longer than signal!")

            if duration is not None and offset + duration >= file_length:
                warnings.warn("offset + duration are longer than the signal. Reading until end of signal...",
                              UserWarning)

            audio_input, self.sample_rate = librosa.load(input_file_path,
                                                         sr=None,
                                                         offset=offset,
                                                         duration=duration,
                                                         mono=False)

            // Change from fixed point to floating point
            if not np.issubdtype(audio_input.dtype, float):
                audio_input = audio_input.astype("float") / (np.iinfo(audio_input.dtype).max + 1.0)

            self.audio_data = audio_input

        except Exception as e:
            if isinstance(e, ValueError):  // This is the error we just raise, re-raise it
                raise e
            else:
                raise IOError("Cannot read from file, {file}".format(file=input_file_path))

        self.path_to_input_file = input_file_path
        self.set_active_region_to_default()

    def load_audio_from_array(self, signal, sample_rate=constants.DEFAULT_SAMPLE_RATE):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 13

Instances


Project Name: interactiveaudiolab/nussl
Commit Name: d5f74cc30a8f0a192d5ef8818c6d72c3707c4a97
Time: 2017-02-04
Author: ethanmanilow@gmail.com
File Name: nussl/audio_signal.py
Class Name: AudioSignal
Method Name: load_audio_from_file


Project Name: interactiveaudiolab/nussl
Commit Name: efc54499191ead69f875877badd3578c60eba7a6
Time: 2017-02-08
Author: ethanmanilow@gmail.com
File Name: nussl/audio_signal.py
Class Name: AudioSignal
Method Name: load_audio_from_file


Project Name: chainer/chainercv
Commit Name: 44edfba78536668c2240e8e722029741a547bd9a
Time: 2018-11-20
Author: yuyuniitani@gmail.com
File Name: chainercv/transforms/image/rotate.py
Class Name:
Method Name: rotate