def insert(self, x: np.ndarray) -> np.ndarray:
        """
        :param x: N x L matrix or length L array, where N is number of examples, L is the length in number of samples.
                  X is in range [-1,1].
        :return: Backdoored audio.
        """
        n_dim = len(x.shape)
        if n_dim == 2:
            return np.array([self.insert(single_audio) for single_audio in x])
        if n_dim != 1:
            raise ValueError("Invalid array shape " + str(x.shape))
        original_dtype = x.dtype
        audio = np.copy(x)
        length = audio.shape[0]
        bd_length = self.trigger.shape[0]
        if bd_length > length:
            raise ValueError("Backdoor audio does not fit inside the original audio.")
        if self.random:
            shift = np.random.randint(length - bd_length)
        else:
            shift = self.shift
        if shift + bd_length > length:
            raise ValueError("Shift + Backdoor length is greater than audio's length.")

        audio[shift : shift + bd_length] += self.scaled_trigger
        audio = np.clip(audio, -1.0, 1.0)
        return audio.astype(original_dtype)

        :param x: N x L matrix or length L array, where N is number of examples, L is the length in number of samples.
                  X is in range [-1,1].
        :return: Backdoored audio.
        
art/attacks/poisoning/perturbations/audio_perturbations.py