# HG changeset patch # User Amine Sehili # Date 1546460141 -3600 # Node ID ef6d0f0a9cd2ee4d4064d2e66dfb3c8e7f684177 # Parent 22769f0c8d4ac747b76cd46636181187885ea426 Add methods for duration in sec and ms to AudioRegion diff -r 22769f0c8d4a -r ef6d0f0a9cd2 auditok/core.py --- a/auditok/core.py Wed Jan 02 21:09:29 2019 +0100 +++ b/auditok/core.py Wed Jan 02 21:15:41 2019 +0100 @@ -50,6 +50,11 @@ return self._end @property + def duration(self): + """Region duration in seconds""" + return self._duration + + @property def sampling_rate(self): return self._sample_width @@ -73,6 +78,10 @@ def ch(self): return self._channels + def __len__(self): + """Region duration in milliseconds""" + return int(self._duration * 1000) + class StreamTokenizer(): """