# HG changeset patch # User Amine Sehili # Date 1729339358 -7200 # Node ID 912bec5a58ed02fb72ff538872d375771d531e27 # Parent 5e2fe07cd12f9c5756024fbb76ac43695bd3fbd3 Refactor AudioRegion diff -r 5e2fe07cd12f -r 912bec5a58ed auditok/core.py --- a/auditok/core.py Fri Oct 18 23:45:16 2024 +0200 +++ b/auditok/core.py Sat Oct 19 14:02:38 2024 +0200 @@ -649,10 +649,7 @@ def __post_init__(self): check_audio_data(self.data, self.sample_width, self.channels) - object.__setattr__(self, "splitp", self.split_and_plot) - object.__setattr__(self, "_samples", None) - duration = len(self.data) / ( self.sampling_rate * self.sample_width * self.channels ) @@ -980,18 +977,20 @@ @property def samples(self): - """Audio region as arrays of samples, one array per channel.""" - if self._samples is None: # TODO fixit - _samples = signal.to_array( - self.data, self.sample_width, self.channels - ) - return _samples + warnings.warn( + "`AudioRegion.samples` is deprecated and will be removed in future " + "versions. Please use `AudioRegion.numpy()`.", + DeprecationWarning, + stacklevel=2, + ) + return self.numpy() def __array__(self): - return self.samples + return self.numpy() def numpy(self): - return self.samples + """Audio region a 2D numpy array of shape (n_channels, n_samples).""" + return signal.to_array(self.data, self.sample_width, self.channels) def __len__(self): """