Mercurial > hg > auditok
changeset 83:b317c6e90130
Implement __repr__, __str__ and __bytes__ for AudioRegion
author | Amine Sehili <amine.sehili@gmail.com> |
---|---|
date | Thu, 03 Jan 2019 20:41:22 +0100 |
parents | ef6d0f0a9cd2 |
children | c4e233ffd355 |
files | auditok/core.py |
diffstat | 1 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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(): """