Skip to content

Commit dc36258

Browse files
committed
callback as it was printing the transcription with timestamps
1 parent 29a4ae1 commit dc36258

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/rcpp_whisper.cpp

+6-12
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,7 @@ void whisper_print_segment_callback(struct whisper_context * ctx, struct whisper
180180
t1 = whisper_full_get_segment_t1(ctx, i);
181181
}
182182

183-
if (!params.no_timestamps) {
184-
Rprintf("[%s --> %s] ", to_timestamp(t0).c_str(), to_timestamp(t1).c_str());
185-
}
186-
183+
187184
if (params.diarize && pcmf32s.size() == 2) {
188185
speaker = estimate_diarization_speaker(pcmf32s, t0, t1);
189186
}
@@ -206,21 +203,18 @@ void whisper_print_segment_callback(struct whisper_context * ctx, struct whisper
206203
}
207204
} else {
208205
const char * text = whisper_full_get_segment_text(ctx, i);
209-
210-
Rprintf("%s%s", speaker.c_str(), text);
206+
if (!params.no_timestamps) {
207+
Rprintf("[%s --> %s] %s%s\n", to_timestamp(t0).c_str(), to_timestamp(t1).c_str(), speaker.c_str(), text);
208+
}else{
209+
Rprintf("%s%s\n", speaker.c_str(), text);
210+
}
211211
}
212212

213213
if (params.tinydiarize) {
214214
if (whisper_full_get_segment_speaker_turn_next(ctx, i)) {
215215
Rprintf("%s", params.tdrz_speaker_turn.c_str());
216216
}
217217
}
218-
219-
// with timestamps or speakers: each segment on new line
220-
if (!params.no_timestamps || params.diarize) {
221-
Rprintf("\n");
222-
}
223-
224218
Rcpp::checkUserInterrupt();
225219
}
226220
}

0 commit comments

Comments
 (0)