Mercurial > hg > auditok
changeset 422:912bec5a58ed
Refactor AudioRegion
author | Amine Sehili <amine.sehili@gmail.com> |
---|---|
date | Sat, 19 Oct 2024 14:02:38 +0200 |
parents | 5e2fe07cd12f |
children | 88e99cfd9c4c |
files | auditok/core.py |
diffstat | 1 files changed, 10 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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): """