mirror of
https://github.com/openai/whisper.git
synced 2025-11-24 14:35:57 +00:00
Merge e8ea46f6b47bc2c2694cb4a1e3bed3c03806eb15 into c0d2f624c09dc18e709e37c2ad90c039a4eb72a2
This commit is contained in:
commit
d02f72858c
@ -50,7 +50,9 @@ def compression_ratio(text) -> float:
|
|||||||
def format_timestamp(
|
def format_timestamp(
|
||||||
seconds: float, always_include_hours: bool = False, decimal_marker: str = "."
|
seconds: float, always_include_hours: bool = False, decimal_marker: str = "."
|
||||||
):
|
):
|
||||||
assert seconds >= 0, "non-negative timestamp expected"
|
sign = "-" if seconds < 0 else ""
|
||||||
|
seconds = abs(seconds)
|
||||||
|
|
||||||
milliseconds = round(seconds * 1000.0)
|
milliseconds = round(seconds * 1000.0)
|
||||||
|
|
||||||
hours = milliseconds // 3_600_000
|
hours = milliseconds // 3_600_000
|
||||||
@ -64,7 +66,7 @@ def format_timestamp(
|
|||||||
|
|
||||||
hours_marker = f"{hours:02d}:" if always_include_hours or hours > 0 else ""
|
hours_marker = f"{hours:02d}:" if always_include_hours or hours > 0 else ""
|
||||||
return (
|
return (
|
||||||
f"{hours_marker}{minutes:02d}:{seconds:02d}{decimal_marker}{milliseconds:03d}"
|
f"{sign}{hours_marker}{minutes:02d}:{seconds:02d}{decimal_marker}{milliseconds:03d}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user