mirror of
https://github.com/chidiwilliams/buzz.git
synced 2024-06-26 11:40:09 +02:00
Use comma as SRT separator (#280)
This commit is contained in:
parent
f6ef2d5fe3
commit
5f9045c347
|
@ -7,4 +7,4 @@ omit =
|
|||
directory = coverage/html
|
||||
|
||||
[report]
|
||||
fail_under = 74
|
||||
fail_under = 73
|
||||
|
|
|
@ -474,7 +474,7 @@ def write_output(path: str, segments: List[Segment], should_open: bool, output_f
|
|||
for (i, segment) in enumerate(segments):
|
||||
file.write(f'{i + 1}\n')
|
||||
file.write(
|
||||
f'{to_timestamp(segment.start)} --> {to_timestamp(segment.end)}\n')
|
||||
f'{to_timestamp(segment.start, ms_separator=",")} --> {to_timestamp(segment.end, ms_separator=",")}\n')
|
||||
file.write(f'{segment.text}\n\n')
|
||||
|
||||
if should_open:
|
||||
|
@ -495,14 +495,14 @@ def segments_to_text(segments: List[Segment]) -> str:
|
|||
return result
|
||||
|
||||
|
||||
def to_timestamp(ms: float) -> str:
|
||||
def to_timestamp(ms: float, ms_separator='.') -> str:
|
||||
hr = int(ms / (1000 * 60 * 60))
|
||||
ms = ms - hr * (1000 * 60 * 60)
|
||||
min = int(ms / (1000 * 60))
|
||||
ms = ms - min * (1000 * 60)
|
||||
sec = int(ms / 1000)
|
||||
ms = int(ms - sec * 1000)
|
||||
return f'{hr:02d}:{min:02d}:{sec:02d}.{ms:03d}'
|
||||
return f'{hr:02d}:{min:02d}:{sec:02d}{ms_separator}{ms:03d}'
|
||||
|
||||
|
||||
SUPPORTED_OUTPUT_FORMATS = 'Audio files (*.mp3 *.wav *.m4a *.ogg);;\
|
||||
|
|
|
@ -205,7 +205,7 @@ class TestWhisperCpp:
|
|||
(OutputFormat.TXT, 'Bien venue dans\n'),
|
||||
(
|
||||
OutputFormat.SRT,
|
||||
'1\n00:00:00.040 --> 00:00:00.299\nBien\n\n2\n00:00:00.299 --> 00:00:00.329\nvenue dans\n\n'),
|
||||
'1\n00:00:00,040 --> 00:00:00,299\nBien\n\n2\n00:00:00,299 --> 00:00:00,329\nvenue dans\n\n'),
|
||||
(OutputFormat.VTT,
|
||||
'WEBVTT\n\n00:00:00.040 --> 00:00:00.299\nBien\n\n00:00:00.299 --> 00:00:00.329\nvenue dans\n\n'),
|
||||
])
|
||||
|
|
Loading…
Reference in a new issue