From 0abfa84adf2c5966f651be89a564dc3a3e242c62 Mon Sep 17 00:00:00 2001 From: magicse Date: Mon, 21 Oct 2024 16:19:45 +0300 Subject: [PATCH] Update whisper.py 1 sec = 1000 msec to correct calc min also when calculating hours, minutes, or seconds need use floor division. --- whisper_cpp_python/whisper.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/whisper_cpp_python/whisper.py b/whisper_cpp_python/whisper.py index 7c1e5f1..4efca4a 100644 --- a/whisper_cpp_python/whisper.py +++ b/whisper_cpp_python/whisper.py @@ -125,13 +125,13 @@ def __dealloc__(self): whisper_cpp.whisper_free(ctypes.c_void_p(self.context)) @staticmethod - def format_time(t: int): - msec = t * 10 - hr = msec / (1000 * 60 * 60) + def format_time(t: float): + msec = t * 1000 + hr = msec // (1000 * 60 * 60) msec = msec - hr * (1000 * 60 * 60) - minu = msec / (1000 * 60) + minu = msec // (1000 * 60) msec = msec - minu * (1000 * 60) - sec = msec / 1000 + sec = msec // 1000 msec = msec - sec * 1000 return f'{int(hr):02}:{int(minu):02}:{int(sec):02}.{int(msec):03}'