Skip to content

Commit

Permalink
main : add csv header (#552)
Browse files Browse the repository at this point in the history
  • Loading branch information
hykelvinlee42 authored Mar 2, 2023
1 parent af005d5 commit 72af0f5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,14 @@ bool output_csv(struct whisper_context * ctx, const char * fname) {
fprintf(stderr, "%s: saving output to '%s'\n", __func__, fname);

const int n_segments = whisper_full_n_segments(ctx);
fout << "start,end,text\n";
for (int i = 0; i < n_segments; ++i) {
const char * text = whisper_full_get_segment_text(ctx, i);
const int64_t t0 = whisper_full_get_segment_t0(ctx, i);
const int64_t t1 = whisper_full_get_segment_t1(ctx, i);

//need to multiply times returned from whisper_full_get_segment_t{0,1}() by 10 to get milliseconds.
fout << 10 * t0 << ", " << 10 * t1 << ", \"" << text << "\"\n";
fout << 10 * t0 << "," << 10 * t1 << ",\"" << text << "\"\n";
}

return true;
Expand Down

0 comments on commit 72af0f5

Please sign in to comment.