Skip to content

Commit 29a4ae1

Browse files
committed
printf > Rprintf
1 parent c362b6d commit 29a4ae1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/rcpp_whisper.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void whisper_print_segment_callback(struct whisper_context * ctx, struct whisper
171171
const int s0 = n_segments - n_new;
172172

173173
if (s0 == 0) {
174-
printf("\n");
174+
Rprintf("\n");
175175
}
176176

177177
for (int i = s0; i < n_segments; i++) {
@@ -181,7 +181,7 @@ void whisper_print_segment_callback(struct whisper_context * ctx, struct whisper
181181
}
182182

183183
if (!params.no_timestamps) {
184-
printf("[%s --> %s] ", to_timestamp(t0).c_str(), to_timestamp(t1).c_str());
184+
Rprintf("[%s --> %s] ", to_timestamp(t0).c_str(), to_timestamp(t1).c_str());
185185
}
186186

187187
if (params.diarize && pcmf32s.size() == 2) {
@@ -202,26 +202,26 @@ void whisper_print_segment_callback(struct whisper_context * ctx, struct whisper
202202

203203
const int col = std::max(0, std::min((int) k_colors.size() - 1, (int) (std::pow(p, 3)*float(k_colors.size()))));
204204

205-
printf("%s%s%s%s", speaker.c_str(), k_colors[col].c_str(), text, "\033[0m");
205+
Rprintf("%s%s%s%s", speaker.c_str(), k_colors[col].c_str(), text, "\033[0m");
206206
}
207207
} else {
208208
const char * text = whisper_full_get_segment_text(ctx, i);
209209

210-
printf("%s%s", speaker.c_str(), text);
210+
Rprintf("%s%s", speaker.c_str(), text);
211211
}
212212

213213
if (params.tinydiarize) {
214214
if (whisper_full_get_segment_speaker_turn_next(ctx, i)) {
215-
printf("%s", params.tdrz_speaker_turn.c_str());
215+
Rprintf("%s", params.tdrz_speaker_turn.c_str());
216216
}
217217
}
218218

219219
// with timestamps or speakers: each segment on new line
220220
if (!params.no_timestamps || params.diarize) {
221-
printf("\n");
221+
Rprintf("\n");
222222
}
223223

224-
fflush(stdout);
224+
Rcpp::checkUserInterrupt();
225225
}
226226
}
227227

0 commit comments

Comments
 (0)