# HG changeset patch # User Amine SEHILI # Date 1486291174 -3600 # Node ID 8cfe5e7dc91e3fe99e06c3b832212154d65a5f16 # Parent d52581cfc9b6aa014f55bc8fa285c87c96367e47 Mark AudioSource attributes as read-only properties diff -r d52581cfc9b6 -r 8cfe5e7dc91e auditok/io.py --- a/auditok/io.py Sat Jan 28 13:03:37 2017 +0100 +++ b/auditok/io.py Sun Feb 05 11:39:34 2017 +0100 @@ -69,9 +69,9 @@ if channels != 1: raise ValueError("Only mono audio is currently handled") - self.sampling_rate = sampling_rate - self.sample_width = sample_width - self.channels = channels + self._sampling_rate = sampling_rate + self._sample_width = sample_width + self._channels = channels @abstractmethod def is_open(self): @@ -108,14 +108,29 @@ """ Return the number of samples per second of audio stream """ return self.sampling_rate + @property + def sampling_rate(self): + """ Number of samples per second of audio stream """ + return self._sampling_rate + def get_sample_width(self): """ Return the number of bytes used to represent one audio sample """ return self.sample_width + @property + def sample_width(self): + """ Number of bytes used to represent one audio sample """ + return self._sample_width + def get_channels(self): """ Return the number of channels of this audio source """ return self.channels + @property + def channels(self): + """ Number of channels of this audio source """ + return self._channels + class Rewindable(): """