@@ -85,6 +85,7 @@ struct whisper_params {
85
85
bool output_jsn = false ;
86
86
bool output_jsn_full = false ;
87
87
bool output_lrc = false ;
88
+ bool no_prints = false ;
88
89
bool print_special = false ;
89
90
bool print_colors = false ;
90
91
bool print_progress = false ;
@@ -155,6 +156,7 @@ bool whisper_params_parse(int argc, char ** argv, whisper_params & params) {
155
156
else if (arg == " -oj" || arg == " --output-json" ) { params.output_jsn = true ; }
156
157
else if (arg == " -ojf" || arg == " --output-json-full" ){ params.output_jsn_full = params.output_jsn = true ; }
157
158
else if (arg == " -of" || arg == " --output-file" ) { params.fname_out .emplace_back (argv[++i]); }
159
+ else if (arg == " -np" || arg == " --no-prints" ) { params.no_prints = true ; }
158
160
else if (arg == " -ps" || arg == " --print-special" ) { params.print_special = true ; }
159
161
else if (arg == " -pc" || arg == " --print-colors" ) { params.print_colors = true ; }
160
162
else if (arg == " -pp" || arg == " --print-progress" ) { params.print_progress = true ; }
@@ -212,6 +214,7 @@ void whisper_print_usage(int /*argc*/, char ** argv, const whisper_params & para
212
214
fprintf (stderr, " -oj, --output-json [%-7s] output result in a JSON file\n " , params.output_jsn ? " true" : " false" );
213
215
fprintf (stderr, " -ojf, --output-json-full [%-7s] include more information in the JSON file\n " , params.output_jsn_full ? " true" : " false" );
214
216
fprintf (stderr, " -of FNAME, --output-file FNAME [%-7s] output file path (without file extension)\n " , " " );
217
+ fprintf (stderr, " -np, --no-prints [%-7s] do not print anything other than the results\n " , params.no_prints ? " true" : " false" );
215
218
fprintf (stderr, " -ps, --print-special [%-7s] print special tokens\n " , params.print_special ? " true" : " false" );
216
219
fprintf (stderr, " -pc, --print-colors [%-7s] print colors\n " , params.print_colors ? " true" : " false" );
217
220
fprintf (stderr, " -pp, --print-progress [%-7s] print progress\n " , params.print_progress ? " true" : " false" );
@@ -852,6 +855,9 @@ bool output_lrc(struct whisper_context * ctx, const char * fname, const whisper_
852
855
return true ;
853
856
}
854
857
858
+
859
+ void cb_log_disable (enum ggml_log_level , const char * , void * ) { }
860
+
855
861
int main (int argc, char ** argv) {
856
862
whisper_params params;
857
863
@@ -878,6 +884,10 @@ int main(int argc, char ** argv) {
878
884
exit (0 );
879
885
}
880
886
887
+ if (params.no_prints ) {
888
+ whisper_log_set (cb_log_disable, NULL );
889
+ }
890
+
881
891
// whisper init
882
892
883
893
struct whisper_context_params cparams;
@@ -905,26 +915,25 @@ int main(int argc, char ** argv) {
905
915
continue ;
906
916
}
907
917
908
- // print system information
909
- {
918
+ if (!whisper_is_multilingual (ctx)) {
919
+ if (params.language != " en" || params.translate ) {
920
+ params.language = " en" ;
921
+ params.translate = false ;
922
+ fprintf (stderr, " %s: WARNING: model is not multilingual, ignoring language and translation options\n " , __func__);
923
+ }
924
+ }
925
+ if (params.detect_language ) {
926
+ params.language = " auto" ;
927
+ }
928
+
929
+ if (!params.no_prints ) {
930
+ // print system information
910
931
fprintf (stderr, " \n " );
911
932
fprintf (stderr, " system_info: n_threads = %d / %d | %s\n " ,
912
933
params.n_threads *params.n_processors , std::thread::hardware_concurrency (), whisper_print_system_info ());
913
- }
914
934
915
- // print some info about the processing
916
- {
935
+ // print some info about the processing
917
936
fprintf (stderr, " \n " );
918
- if (!whisper_is_multilingual (ctx)) {
919
- if (params.language != " en" || params.translate ) {
920
- params.language = " en" ;
921
- params.translate = false ;
922
- fprintf (stderr, " %s: WARNING: model is not multilingual, ignoring language and translation options\n " , __func__);
923
- }
924
- }
925
- if (params.detect_language ) {
926
- params.language = " auto" ;
927
- }
928
937
fprintf (stderr, " %s: processing '%s' (%d samples, %.1f sec), %d threads, %d processors, %d beams + best of %d, lang = %s, task = %s, %stimestamps = %d ...\n " ,
929
938
__func__, fname_inp.c_str (), int (pcmf32.size ()), float (pcmf32.size ())/WHISPER_SAMPLE_RATE,
930
939
params.n_threads , params.n_processors , params.beam_size , params.best_of ,
0 commit comments