Spaces:
Sleeping
Sleeping
F1L1P
bobqianic
commited on
examples : Auto lowercase language parameter in main.cpp (#1928)
Browse files* Auto lowercase language parameter
* Update examples/main/main.cpp
Co-authored-by: bobqianic <[email protected]>
---------
Co-authored-by: bobqianic <[email protected]>
- examples/main/main.cpp +9 -1
examples/main/main.cpp
CHANGED
|
@@ -82,6 +82,14 @@ struct whisper_params {
|
|
| 82 |
|
| 83 |
void whisper_print_usage(int argc, char ** argv, const whisper_params & params);
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
bool whisper_params_parse(int argc, char ** argv, whisper_params & params) {
|
| 86 |
for (int i = 1; i < argc; i++) {
|
| 87 |
std::string arg = argv[i];
|
|
@@ -135,7 +143,7 @@ bool whisper_params_parse(int argc, char ** argv, whisper_params & params) {
|
|
| 135 |
else if (arg == "-pc" || arg == "--print-colors") { params.print_colors = true; }
|
| 136 |
else if (arg == "-pp" || arg == "--print-progress") { params.print_progress = true; }
|
| 137 |
else if (arg == "-nt" || arg == "--no-timestamps") { params.no_timestamps = true; }
|
| 138 |
-
else if (arg == "-l" || arg == "--language") { params.language = argv[++i]; }
|
| 139 |
else if (arg == "-dl" || arg == "--detect-language") { params.detect_language = true; }
|
| 140 |
else if ( arg == "--prompt") { params.prompt = argv[++i]; }
|
| 141 |
else if (arg == "-m" || arg == "--model") { params.model = argv[++i]; }
|
|
|
|
| 82 |
|
| 83 |
void whisper_print_usage(int argc, char ** argv, const whisper_params & params);
|
| 84 |
|
| 85 |
+
char* whisper_param_turn_lowercase(char* in){
|
| 86 |
+
int string_len = strlen(in);
|
| 87 |
+
for(int i = 0; i < string_len; i++){
|
| 88 |
+
*(in+i) = tolower((unsigned char)*(in+i));
|
| 89 |
+
}
|
| 90 |
+
return in;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
bool whisper_params_parse(int argc, char ** argv, whisper_params & params) {
|
| 94 |
for (int i = 1; i < argc; i++) {
|
| 95 |
std::string arg = argv[i];
|
|
|
|
| 143 |
else if (arg == "-pc" || arg == "--print-colors") { params.print_colors = true; }
|
| 144 |
else if (arg == "-pp" || arg == "--print-progress") { params.print_progress = true; }
|
| 145 |
else if (arg == "-nt" || arg == "--no-timestamps") { params.no_timestamps = true; }
|
| 146 |
+
else if (arg == "-l" || arg == "--language") { params.language = whisper_param_turn_lowercase(argv[++i]); }
|
| 147 |
else if (arg == "-dl" || arg == "--detect-language") { params.detect_language = true; }
|
| 148 |
else if ( arg == "--prompt") { params.prompt = argv[++i]; }
|
| 149 |
else if (arg == "-m" || arg == "--model") { params.model = argv[++i]; }
|