Files
UltraSinger/src/modules/timer.py
T
Benedikt Wagener de45b7c96a downgrade tensorflow dependency, improve plot, add timer
downgrade tensorflow dependency to last version with gpu support for windows
update plot to be a linear progression between notes on the y axis and include confidence information
add timer component to measure process time
2023-09-13 23:56:42 +02:00

27 lines
560 B
Python

import atexit
from functools import reduce
from time import process_time
from modules.console_colors import ULTRASINGER_HEAD
def seconds_to_str(t):
"""Format seconds to string"""
return "%d:%02d:%02d.%03d" % reduce(
lambda ll, b: divmod(ll[0], b) + ll[1:], [(t * 1000,), 1000, 60, 60]
)
def log(s):
"""Log line with optional time elapsed"""
print(f"{ULTRASINGER_HEAD} {seconds_to_str(process_time())} - {s}")
def end_log():
"""Log at program end"""
log("End Program")
atexit.register(end_log)
log("Initialized...")