Spaces:
Running
Running
node : enable no_prints to suppress all output (#3189)
Browse filesThis 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: https://github.com/ggml-org/whisper.cpp/issues/3176
examples/addon.node/addon.cpp
CHANGED
|
@@ -82,7 +82,7 @@ void whisper_print_segment_callback(struct whisper_context * ctx, struct whisper
|
|
| 82 |
t1 = whisper_full_get_segment_t1(ctx, i);
|
| 83 |
}
|
| 84 |
|
| 85 |
-
if (!params.no_timestamps) {
|
| 86 |
printf("[%s --> %s] ", to_timestamp(t0).c_str(), to_timestamp(t1).c_str());
|
| 87 |
}
|
| 88 |
|
|
@@ -113,12 +113,14 @@ void whisper_print_segment_callback(struct whisper_context * ctx, struct whisper
|
|
| 113 |
|
| 114 |
// colorful print bug
|
| 115 |
//
|
| 116 |
-
|
| 117 |
-
|
|
|
|
|
|
|
| 118 |
|
| 119 |
|
| 120 |
// with timestamps or speakers: each segment on new line
|
| 121 |
-
if (!params.no_timestamps || params.diarize) {
|
| 122 |
printf("\n");
|
| 123 |
}
|
| 124 |
|
|
|
|
| 82 |
t1 = whisper_full_get_segment_t1(ctx, i);
|
| 83 |
}
|
| 84 |
|
| 85 |
+
if (!params.no_timestamps && !params.no_prints) {
|
| 86 |
printf("[%s --> %s] ", to_timestamp(t0).c_str(), to_timestamp(t1).c_str());
|
| 87 |
}
|
| 88 |
|
|
|
|
| 113 |
|
| 114 |
// colorful print bug
|
| 115 |
//
|
| 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 |
+
}
|
| 120 |
|
| 121 |
|
| 122 |
// with timestamps or speakers: each segment on new line
|
| 123 |
+
if ((!params.no_timestamps || params.diarize) && !params.no_prints) {
|
| 124 |
printf("\n");
|
| 125 |
}
|
| 126 |
|