From cc49374096c039a405a73bb2f78457268407a55e Mon Sep 17 00:00:00 2001 From: HeNine <> Date: Sun, 7 Nov 2021 12:59:22 +0100 Subject: [PATCH] Change start time priority to make database take priority --- buscribe/buscribe/main.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/buscribe/buscribe/main.py b/buscribe/buscribe/main.py index 7f3df00..3356404 100644 --- a/buscribe/buscribe/main.py +++ b/buscribe/buscribe/main.py @@ -44,20 +44,22 @@ def main(channel, database="", base_dir=".", logging.debug("Got database cursor.") logging.info("Figuring out starting time...") - if start_time is not None: + db_start_time = get_end_of_transcript(db_cursor) + + # Database start time takes priority + if db_start_time is not None: + start_time = db_start_time + elif start_time is not None: start_time = dateutil.parse(start_time) else: - start_time = get_end_of_transcript(db_cursor) - - if end_time is not None: - end_time = dateutil.parse(end_time) - - # No start time argument AND no end of transcript (empty database) - if start_time is None: + # No start time argument AND no end of transcript (empty database) logging.error("Couldn't figure out start time!") db_conn.close() exit(1) + if end_time is not None: + end_time = dateutil.parse(end_time) + logging.info("Loading models...") recognizer = BuscribeRecognizer(SAMPLE_RATE, model, spk_model) logging.info("Models loaded.") @@ -77,7 +79,7 @@ def main(channel, database="", base_dir=".", gevent.signal_handler(signal.SIGTERM, stop) - while True: + while start_time < end_time: # If end time isn't given, use current time (plus fudge) to get a "live" segment list segments = common.get_best_segments(segments_dir, start_time,