HY. Kelvin Lee commited on
Commit
f4877ed
·
unverified ·
1 Parent(s): 27ce621

main : add csv header (#552)

Browse files
Files changed (1) hide show
  1. examples/main/main.cpp +2 -1
examples/main/main.cpp CHANGED
@@ -352,13 +352,14 @@ bool output_csv(struct whisper_context * ctx, const char * fname) {
352
  fprintf(stderr, "%s: saving output to '%s'\n", __func__, fname);
353
 
354
  const int n_segments = whisper_full_n_segments(ctx);
 
355
  for (int i = 0; i < n_segments; ++i) {
356
  const char * text = whisper_full_get_segment_text(ctx, i);
357
  const int64_t t0 = whisper_full_get_segment_t0(ctx, i);
358
  const int64_t t1 = whisper_full_get_segment_t1(ctx, i);
359
 
360
  //need to multiply times returned from whisper_full_get_segment_t{0,1}() by 10 to get milliseconds.
361
- fout << 10 * t0 << ", " << 10 * t1 << ", \"" << text << "\"\n";
362
  }
363
 
364
  return true;
 
352
  fprintf(stderr, "%s: saving output to '%s'\n", __func__, fname);
353
 
354
  const int n_segments = whisper_full_n_segments(ctx);
355
+ fout << "start,end,text\n";
356
  for (int i = 0; i < n_segments; ++i) {
357
  const char * text = whisper_full_get_segment_text(ctx, i);
358
  const int64_t t0 = whisper_full_get_segment_t0(ctx, i);
359
  const int64_t t1 = whisper_full_get_segment_t1(ctx, i);
360
 
361
  //need to multiply times returned from whisper_full_get_segment_t{0,1}() by 10 to get milliseconds.
362
+ fout << 10 * t0 << "," << 10 * t1 << ",\"" << text << "\"\n";
363
  }
364
 
365
  return true;