@@ -36,7 +36,9 @@ struct whisper_params {
36
36
bool print_colors = false ;
37
37
bool print_progress = false ;
38
38
bool no_timestamps = false ;
39
+ bool no_prints = false ;
39
40
bool use_gpu = true ;
41
+ bool comma_in_time = true ;
40
42
41
43
std::string language = " en" ;
42
44
std::string prompt;
@@ -120,7 +122,14 @@ void whisper_print_segment_callback(struct whisper_context * ctx, struct whisper
120
122
}
121
123
}
122
124
125
+ void cb_log_disable (enum ggml_log_level, const char *, void *) {}
126
+
123
127
int run (whisper_params ¶ms, std::vector<std::vector<std::string>> &result) {
128
+
129
+ if (params.no_prints ) {
130
+ whisper_log_set (cb_log_disable, NULL );
131
+ }
132
+
124
133
if (params.fname_inp .empty ()) {
125
134
fprintf (stderr, " error: no input files specified\n " );
126
135
return 2 ;
@@ -155,14 +164,14 @@ int run(whisper_params ¶ms, std::vector<std::vector<std::string>> &result) {
155
164
}
156
165
157
166
// print system information
158
- {
167
+ if (!params. no_prints ) {
159
168
fprintf (stderr, " \n " );
160
169
fprintf (stderr, " system_info: n_threads = %d / %d | %s\n " ,
161
170
params.n_threads *params.n_processors , std::thread::hardware_concurrency (), whisper_print_system_info ());
162
171
}
163
172
164
173
// print some info about the processing
165
- {
174
+ if (!params. no_prints ) {
166
175
fprintf (stderr, " \n " );
167
176
if (!whisper_is_multilingual (ctx)) {
168
177
if (params.language != " en" || params.translate ) {
@@ -248,8 +257,8 @@ int run(whisper_params ¶ms, std::vector<std::vector<std::string>> &result) {
248
257
const int64_t t0 = whisper_full_get_segment_t0 (ctx, i);
249
258
const int64_t t1 = whisper_full_get_segment_t1 (ctx, i);
250
259
251
- result[i].emplace_back (to_timestamp (t0, true ));
252
- result[i].emplace_back (to_timestamp (t1, true ));
260
+ result[i].emplace_back (to_timestamp (t0, params. comma_in_time ));
261
+ result[i].emplace_back (to_timestamp (t1, params. comma_in_time ));
253
262
result[i].emplace_back (text);
254
263
}
255
264
@@ -300,13 +309,17 @@ Napi::Value whisper(const Napi::CallbackInfo& info) {
300
309
std::string model = whisper_params.Get (" model" ).As <Napi::String>();
301
310
std::string input = whisper_params.Get (" fname_inp" ).As <Napi::String>();
302
311
bool use_gpu = whisper_params.Get (" use_gpu" ).As <Napi::Boolean>();
312
+ bool no_prints = whisper_params.Get (" no_prints" ).As <Napi::Boolean>();
303
313
bool no_timestamps = whisper_params.Get (" no_timestamps" ).As <Napi::Boolean>();
314
+ bool comma_in_time = whisper_params.Get (" comma_in_time" ).As <Napi::Boolean>();
304
315
305
316
params.language = language;
306
317
params.model = model;
307
318
params.fname_inp .emplace_back (input);
308
319
params.use_gpu = use_gpu;
320
+ params.no_prints = no_prints;
309
321
params.no_timestamps = no_timestamps;
322
+ params.comma_in_time = comma_in_time;
310
323
311
324
Napi::Function callback = info[1 ].As <Napi::Function>();
312
325
Worker* worker = new Worker (callback, params);
0 commit comments