Skip to content

Commit 54373c4

Browse files
committed
Add 'duration' to output keywords
1 parent 793e580 commit 54373c4

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

auditok/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
from . import dataset
1717
from .exceptions import *
1818

19-
__version__ = "0.1.5"
19+
__version__ = "0.1.6"
2020

2121

auditok/cmdline.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
1010
@author: Mohamed El Amine SEHILI
1111
12-
@copyright: 2015 Mohamed El Amine SEHILI
12+
@copyright: 2015-2016 Mohamed El Amine SEHILI
1313
1414
@license: GPL v3
1515
1616
@contact: amine.sehili@gmail.com
17-
@deffield updated: 02 Dec 2015
17+
@deffield updated: 13 May 2016
1818
'''
1919

2020
import sys
@@ -52,7 +52,7 @@
5252
__all__ = []
5353
__version__ = version
5454
__date__ = '2015-11-23'
55-
__updated__ = '2015-03-11'
55+
__updated__ = '2016-05-13'
5656

5757
DEBUG = 0
5858
TESTRUN = 1
@@ -511,6 +511,7 @@ def run(self):
511511
end = message.pop("end", None)
512512
start_time = message.pop("start_time", None)
513513
end_time = message.pop("end_time", None)
514+
duration = message.pop("duration", None)
514515
if audio_data is not None and len(audio_data) > 0:
515516

516517
if self.debug:
@@ -521,7 +522,7 @@ def run(self):
521522
if self.print_detections:
522523
print(self.output_format.format(id = _id,
523524
start = self.time_formatter(start_time),
524-
end = self.time_formatter(end_time)))
525+
end = self.time_formatter(end_time), duration = self.time_formatter(duration)))
525526

526527
self.detections.append((_id, start, end, start_time, end_time))
527528

@@ -582,7 +583,7 @@ def main(argv=None):
582583
group.add_option("-E", "--echo", dest="echo", help="Play back each detection immediately using pyaudio [default: do not play]", action="store_true", default=False)
583584
group.add_option("-p", "--plot", dest="plot", help="Plot and show audio signal and detections (requires matplotlib)", action="store_true", default=False)
584585
group.add_option("", "--save-image", dest="save_image", help="Save plotted audio signal and detections as a picture or a PDF file (requires matplotlib)", type=str, default=None, metavar="FILE")
585-
group.add_option("", "--printf", dest="printf", help="print detections one per line using a user supplied format (e.g. '[{id}]: {start} -- {end}'). Available keywords {id}, {start} and {end}", type=str, default="{id} {start} {end}", metavar="STRING")
586+
group.add_option("", "--printf", dest="printf", help="print detections, one per line, using a user supplied format (e.g. '[{id}]: {start} -- {end}'). Available keywords {id}, {start}, {end} and {duration}", type=str, default="{id} {start} {end}", metavar="STRING")
586587
group.add_option("", "--time-format", dest="time_format", help="format used to print {start} and {end}. [Default= %default]. %S: absolute time in sec. %I: absolute time in ms. If at least one of (%h, %m, %s, %i) is used, convert time into hours, minutes, seconds and millis (e.g. %h:%m:%s.%i). Only required fields are printed", type=str, default="%S", metavar="STRING")
587588
parser.add_option_group(group)
588589

0 commit comments

Comments
 (0)