]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
examples : Auto lowercase language parameter in main.cpp (#1928)
authorF1L1P <redacted>
Wed, 6 Mar 2024 22:25:10 +0000 (23:25 +0100)
committerGitHub <redacted>
Wed, 6 Mar 2024 22:25:10 +0000 (22:25 +0000)
* Auto lowercase language parameter

* Update examples/main/main.cpp

Co-authored-by: bobqianic <redacted>
---------

Co-authored-by: bobqianic <redacted>
examples/main/main.cpp

index cef96306aa58d636614c67bfecb1f2759966a806..84db6a0c32dc2c223df7e69424541c9b589320fc 100644 (file)
@@ -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]; }