mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-12-20 21:23:06 +00:00
main : check if input files exist before proceeding (#1872)
Until the most recent commit (3d42463
), the main.cpp sample file does
not check whether the input files exist or not. Consequently, the
model is loaded first before reporting whether there was a failure or
not when processing a file. In environments with HDD, this can take
about 50 seconds or more, depending on the loaded model.
This commit addresses this issue by checking in advance whether the
input files exist or not.
This commit is contained in:
parent
07d04280be
commit
dda4b0ed06
@ -10,6 +10,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#pragma warning(disable: 4244 4267) // possible loss of data
|
#pragma warning(disable: 4244 4267) // possible loss of data
|
||||||
#endif
|
#endif
|
||||||
@ -841,6 +843,20 @@ int main(int argc, char ** argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove non-existent files
|
||||||
|
for (auto it = params.fname_inp.begin(); it != params.fname_inp.end();) {
|
||||||
|
struct stat st;
|
||||||
|
const auto fname_inp = it->c_str();
|
||||||
|
|
||||||
|
if (stat(fname_inp, &st) == -1) {
|
||||||
|
fprintf(stderr, "error: input file not found '%s'\n", fname_inp);
|
||||||
|
it = params.fname_inp.erase(it);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
|
||||||
if (params.fname_inp.empty()) {
|
if (params.fname_inp.empty()) {
|
||||||
fprintf(stderr, "error: no input files specified\n");
|
fprintf(stderr, "error: no input files specified\n");
|
||||||
whisper_print_usage(argc, argv, params);
|
whisper_print_usage(argc, argv, params);
|
||||||
|
Loading…
Reference in New Issue
Block a user