Add command-line version (fixes #608)
Adds version to whisper.h under CMake builds and exposes as --version in main executable. Plain Makefile builds have --version disabled.pull/1627/head
parent
6335933a5b
commit
3c3e649eee
|
@ -17,8 +17,10 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
|||
configure_file(${CMAKE_SOURCE_DIR}/bindings/ios/Makefile-tmpl ${CMAKE_SOURCE_DIR}/bindings/ios/Makefile @ONLY)
|
||||
endif()
|
||||
configure_file(${CMAKE_SOURCE_DIR}/bindings/javascript/package-tmpl.json ${CMAKE_SOURCE_DIR}/bindings/javascript/package.json @ONLY)
|
||||
configure_file(whisper.h.in ${CMAKE_SOURCE_DIR}/whisper.h @ONLY)
|
||||
else()
|
||||
set(WHISPER_STANDALONE OFF)
|
||||
configure_file(whisper.h.in ${CMAKE_CURRENT_SOURCE_DIR}/whisper.h @ONLY)
|
||||
endif()
|
||||
|
||||
if (EMSCRIPTEN)
|
||||
|
|
3
Makefile
3
Makefile
|
@ -295,6 +295,9 @@ $(info )
|
|||
# Build library
|
||||
#
|
||||
|
||||
whisper.h: whisper.h.in
|
||||
cp whisper.h.in whisper.h
|
||||
|
||||
ggml.o: ggml.c ggml.h ggml-cuda.h
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
|
|
|
@ -126,6 +126,10 @@ bool whisper_params_parse(int argc, char ** argv, whisper_params & params) {
|
|||
whisper_print_usage(argc, argv, params);
|
||||
exit(0);
|
||||
}
|
||||
if (strcmp(WHISPER_VERSION, "@whisper.cpp_VERSION@") != 0 && (arg == "-v" || arg == "--version")) {
|
||||
fprintf(stderr, "%s\n", WHISPER_VERSION);
|
||||
exit(0);
|
||||
}
|
||||
else if (arg == "-t" || arg == "--threads") { params.n_threads = std::stoi(argv[++i]); }
|
||||
else if (arg == "-p" || arg == "--processors") { params.n_processors = std::stoi(argv[++i]); }
|
||||
else if (arg == "-ot" || arg == "--offset-t") { params.offset_t_ms = std::stoi(argv[++i]); }
|
||||
|
@ -183,6 +187,9 @@ void whisper_print_usage(int /*argc*/, char ** argv, const whisper_params & para
|
|||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "options:\n");
|
||||
fprintf(stderr, " -h, --help [default] show this help message and exit\n");
|
||||
if(strcmp(WHISPER_VERSION, "@whisper.cpp_VERSION@") != 0) {
|
||||
fprintf(stderr, " -v, --version [default] show version number and exit\n");
|
||||
}
|
||||
fprintf(stderr, " -t N, --threads N [%-7d] number of threads to use during computation\n", params.n_threads);
|
||||
fprintf(stderr, " -p N, --processors N [%-7d] number of processors to use during computation\n", params.n_processors);
|
||||
fprintf(stderr, " -ot N, --offset-t N [%-7d] time offset in milliseconds\n", params.offset_t_ms);
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define WHISPER_VERSION "@whisper.cpp_VERSION@"
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define WHISPER_DEPRECATED(func, hint) func __attribute__((deprecated(hint)))
|
||||
#elif defined(_MSC_VER)
|
Loading…
Reference in New Issue