changeset 82:ef6d0f0a9cd2

Add methods for duration in sec and ms to AudioRegion
author Amine Sehili <amine.sehili@gmail.com>
date Wed, 02 Jan 2019 21:15:41 +0100
parents 22769f0c8d4a
children b317c6e90130
files auditok/core.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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():
     """