whisper-jax
whisper-jax copied to clipboard
Is there some code for Whisper jax to produce srt subtitle?
Is there some code for Whisper jax to produce srt subtitle?
srt_data = ""
for index, entry in enumerate(chunks):
start_time, end_time = entry['timestamp']
start_hours, start_minutes, start_seconds = int(start_time // 3600), int((start_time % 3600) // 60), start_time % 60
end_hours, end_minutes, end_seconds = int(end_time // 3600), int((end_time % 3600) // 60), end_time % 60
srt_entry = f"{index + 1}\n{start_hours:02d}:{start_minutes:02d}:{start_seconds:06.3f} --> {end_hours:02d}:{end_minutes:02d}:{end_seconds:06.3f}\n{entry['text']}\n\n"
srt_data += srt_entry
print(srt_data)
with open('output.srt', 'w', encoding='utf-8') as f:
f.write(srt_data)
print("SRT data saved to output.srt")
I use something like the above