From 2e2626b1677161d055531aa9b4d7172a148a7138 Mon Sep 17 00:00:00 2001 From: F1L1P <78918286+F1L1Pv2@users.noreply.github.com> Date: Wed, 6 Mar 2024 23:25:10 +0100 Subject: [PATCH] examples : Auto lowercase language parameter in main.cpp (#1928) * Auto lowercase language parameter * Update examples/main/main.cpp Co-authored-by: bobqianic <129547291+bobqianic@users.noreply.github.com> --------- Co-authored-by: bobqianic <129547291+bobqianic@users.noreply.github.com> --- examples/main/main.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/main/main.cpp b/examples/main/main.cpp index cef9630..84db6a0 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -82,6 +82,14 @@ struct whisper_params { void whisper_print_usage(int argc, char ** argv, const whisper_params & params); +char* whisper_param_turn_lowercase(char* in){ + int string_len = strlen(in); + for(int i = 0; i < string_len; i++){ + *(in+i) = tolower((unsigned char)*(in+i)); + } + return in; +} + bool whisper_params_parse(int argc, char ** argv, whisper_params & params) { for (int i = 1; i < argc; i++) { std::string arg = argv[i]; @@ -135,7 +143,7 @@ bool whisper_params_parse(int argc, char ** argv, whisper_params & params) { else if (arg == "-pc" || arg == "--print-colors") { params.print_colors = true; } else if (arg == "-pp" || arg == "--print-progress") { params.print_progress = true; } else if (arg == "-nt" || arg == "--no-timestamps") { params.no_timestamps = true; } - else if (arg == "-l" || arg == "--language") { params.language = argv[++i]; } + else if (arg == "-l" || arg == "--language") { params.language = whisper_param_turn_lowercase(argv[++i]); } else if (arg == "-dl" || arg == "--detect-language") { params.detect_language = true; } else if ( arg == "--prompt") { params.prompt = argv[++i]; } else if (arg == "-m" || arg == "--model") { params.model = argv[++i]; }