Skip to content

Commit 450de07

Browse files
authored
node : enable no_prints to suppress all output (#3189)
This commit enable the node addon to suppress all output, even the result of the transcription if the no_prints parameter is set to true. The motivation for this is that for the node addon there is a fullfilment handler/success callback to process the transcription result. And it might be useful to be able to disable the printing of the transcription result to the console, so that the user can handle the result in their own way. Refs: #3176
1 parent ea9f206 commit 450de07

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

examples/addon.node/addon.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void whisper_print_segment_callback(struct whisper_context * ctx, struct whisper
8282
t1 = whisper_full_get_segment_t1(ctx, i);
8383
}
8484

85-
if (!params.no_timestamps) {
85+
if (!params.no_timestamps && !params.no_prints) {
8686
printf("[%s --> %s] ", to_timestamp(t0).c_str(), to_timestamp(t1).c_str());
8787
}
8888

@@ -113,12 +113,14 @@ void whisper_print_segment_callback(struct whisper_context * ctx, struct whisper
113113

114114
// colorful print bug
115115
//
116-
const char * text = whisper_full_get_segment_text(ctx, i);
117-
printf("%s%s", speaker.c_str(), text);
116+
if (!params.no_prints) {
117+
const char * text = whisper_full_get_segment_text(ctx, i);
118+
printf("%s%s", speaker.c_str(), text);
119+
}
118120

119121

120122
// with timestamps or speakers: each segment on new line
121-
if (!params.no_timestamps || params.diarize) {
123+
if ((!params.no_timestamps || params.diarize) && !params.no_prints) {
122124
printf("\n");
123125
}
124126

0 commit comments

Comments
 (0)