indent++;
};
- auto end_arr = [&](bool end = false) {
+ auto end_arr = [&](bool end) {
indent--;
doindent();
fout << (end ? "]\n" : "},\n");
};
- auto start_obj = [&](const char *name = nullptr) {
+ auto start_obj = [&](const char *name) {
doindent();
if (name) {
fout << "\"" << name << "\": {\n";
indent++;
};
- auto end_obj = [&](bool end = false) {
+ auto end_obj = [&](bool end) {
indent--;
doindent();
fout << (end ? "}\n" : "},\n");
fout << "\"" << name << "\": ";
};
- auto value_s = [&](const char *name, const char *val, bool end = false) {
+ auto value_s = [&](const char *name, const char *val, bool end) {
start_value(name);
char * val_escaped = escape_double_quotes_and_backslashes(val);
fout << "\"" << val_escaped << (end ? "\"\n" : "\",\n");
free(val_escaped);
};
- auto end_value = [&](bool end = false) {
+ auto end_value = [&](bool end) {
fout << (end ? "\n" : ",\n");
};
- auto value_i = [&](const char *name, const int64_t val, bool end = false) {
+ auto value_i = [&](const char *name, const int64_t val, bool end) {
start_value(name);
fout << val;
end_value(end);
};
- auto value_b = [&](const char *name, const bool val, bool end = false) {
+ auto value_b = [&](const char *name, const bool val, bool end) {
start_value(name);
fout << (val ? "true" : "false");
end_value(end);
}
fprintf(stderr, "%s: saving output to '%s'\n", __func__, fname);
- start_obj();
- value_s("systeminfo", whisper_print_system_info());
+ start_obj(nullptr);
+ value_s("systeminfo", whisper_print_system_info(), false);
start_obj("model");
- value_s("type", whisper_model_type_readable(ctx));
- value_b("multilingual", whisper_is_multilingual(ctx));
- value_i("vocab", whisper_model_n_vocab(ctx));
+ value_s("type", whisper_model_type_readable(ctx), false);
+ value_b("multilingual", whisper_is_multilingual(ctx), false);
+ value_i("vocab", whisper_model_n_vocab(ctx), false);
start_obj("audio");
- value_i("ctx", whisper_model_n_audio_ctx(ctx));
- value_i("state", whisper_model_n_audio_state(ctx));
- value_i("head", whisper_model_n_audio_head(ctx));
+ value_i("ctx", whisper_model_n_audio_ctx(ctx), false);
+ value_i("state", whisper_model_n_audio_state(ctx), false);
+ value_i("head", whisper_model_n_audio_head(ctx), false);
value_i("layer", whisper_model_n_audio_layer(ctx), true);
- end_obj();
+ end_obj(false);
start_obj("text");
- value_i("ctx", whisper_model_n_text_ctx(ctx));
- value_i("state", whisper_model_n_text_state(ctx));
- value_i("head", whisper_model_n_text_head(ctx));
+ value_i("ctx", whisper_model_n_text_ctx(ctx), false);
+ value_i("state", whisper_model_n_text_state(ctx), false);
+ value_i("head", whisper_model_n_text_head(ctx), false);
value_i("layer", whisper_model_n_text_layer(ctx), true);
- end_obj();
- value_i("mels", whisper_model_n_mels(ctx));
+ end_obj(false);
+ value_i("mels", whisper_model_n_mels(ctx), false);
value_i("ftype", whisper_model_ftype(ctx), true);
- end_obj();
+ end_obj(false);
start_obj("params");
- value_s("model", params.model.c_str());
- value_s("language", params.language.c_str());
+ value_s("model", params.model.c_str(), false);
+ value_s("language", params.language.c_str(), false);
value_b("translate", params.translate, true);
- end_obj();
+ end_obj(false);
start_obj("result");
value_s("language", whisper_lang_str(whisper_full_lang_id(ctx)), true);
- end_obj();
+ end_obj(false);
start_arr("transcription");
const int n_segments = whisper_full_n_segments(ctx);
const int64_t t0 = whisper_full_get_segment_t0(ctx, i);
const int64_t t1 = whisper_full_get_segment_t1(ctx, i);
- start_obj();
+ start_obj(nullptr);
start_obj("timestamps");
- value_s("from", to_timestamp(t0, true).c_str());
+ value_s("from", to_timestamp(t0, true).c_str(), false);
value_s("to", to_timestamp(t1, true).c_str(), true);
- end_obj();
+ end_obj(false);
start_obj("offsets");
- value_i("from", t0 * 10);
+ value_i("from", t0 * 10, false);
value_i("to", t1 * 10, true);
- end_obj();
+ end_obj(false);
value_s("text", text, true);
end_obj(i == (n_segments - 1));
}