From: Georgi Gerganov Date: Mon, 24 Oct 2022 15:28:23 +0000 (+0300) Subject: main : fix SRT timestamp to use comma "," instead of dot "." X-Git-Tag: upstream/1.7.4~1906 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=4c68f4cac00ee693106d8501d4f5fb670fe0294e;p=pkg%2Fggml%2Fsources%2Fwhisper.cpp main : fix SRT timestamp to use comma "," instead of dot "." --- diff --git a/main.cpp b/main.cpp index fd1e89e2..3e965e10 100644 --- a/main.cpp +++ b/main.cpp @@ -21,7 +21,7 @@ const std::vector k_colors = { // 500 -> 00:05.000 // 6000 -> 01:00.000 -std::string to_timestamp(int64_t t) { +std::string to_timestamp(int64_t t, bool comma = false) { int64_t msec = t * 10; int64_t hr = msec / (1000 * 60 * 60); msec = msec - hr * (1000 * 60 * 60); @@ -31,7 +31,7 @@ std::string to_timestamp(int64_t t) { msec = msec - sec * 1000; char buf[32]; - snprintf(buf, sizeof(buf), "%02d:%02d:%02d.%03d", (int) hr, (int) min, (int) sec, (int) msec); + snprintf(buf, sizeof(buf), "%02d:%02d:%02d%s%03d", (int) hr, (int) min, (int) sec, comma ? "," : ".", (int) msec); return std::string(buf); } @@ -262,7 +262,7 @@ bool output_srt(struct whisper_context * ctx, const char * fname, const whisper_ const int64_t t1 = whisper_full_get_segment_t1(ctx, i); fout << i + 1 + params.offset_n << "\n"; - fout << to_timestamp(t0) << " --> " << to_timestamp(t1) << "\n"; + fout << to_timestamp(t0, true) << " --> " << to_timestamp(t1, true) << "\n"; fout << text << "\n\n"; }