# HG changeset patch # User Amine Sehili # Date 1546544482 -3600 # Node ID b317c6e90130c356ce25c979b3dae727e3c11fd1 # Parent ef6d0f0a9cd2ee4d4064d2e66dfb3c8e7f684177 Implement __repr__, __str__ and __bytes__ for AudioRegion diff -r ef6d0f0a9cd2 -r b317c6e90130 auditok/core.py --- a/auditok/core.py Wed Jan 02 21:15:41 2019 +0100 +++ b/auditok/core.py Thu Jan 03 20:41:22 2019 +0100 @@ -82,6 +82,22 @@ """Region duration in milliseconds""" return int(self._duration * 1000) + def __bytes__(self): + return self._data + + def __repr__(self): + return ('AudioRegion(data, start={:.3f}, end={:.3f}, ' + 'sampling_rate={}, sample_width={}, channels={})'.format(self.start, + self.end, + self.sr, + self.sw, + self.ch)) + + def __str__(self): + return 'AudioRegion(start={:.3f}, end={:.3f}, duration={:.3f}'.format(self.start, + self.end, + self.duration) + class StreamTokenizer(): """