mirror of
https://github.com/pstrueb/piper.git
synced 2026-05-02 20:38:01 +00:00
Add --version
This commit is contained in:
@@ -5,6 +5,8 @@ project(piper C CXX)
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(SPDLOG REQUIRED spdlog)
|
||||
|
||||
file(READ "${CMAKE_CURRENT_LIST_DIR}/../../VERSION" piper_version)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
@@ -35,3 +37,5 @@ target_include_directories(piper PUBLIC
|
||||
|
||||
target_compile_options(piper PUBLIC
|
||||
${SPDLOG_CFLAGS_OTHER})
|
||||
|
||||
target_compile_definitions(piper PUBLIC _PIPER_VERSION=${piper_version})
|
||||
|
||||
@@ -70,9 +70,10 @@ struct RunConfig {
|
||||
|
||||
// stdin input is lines of JSON instead of text with format:
|
||||
// {
|
||||
// "text": "...", (required)
|
||||
// "text": str, (required)
|
||||
// "speaker_id": int, (optional)
|
||||
// "output_file": "...", (optional)
|
||||
// "speaker": str, (optional)
|
||||
// "output_file": str, (optional)
|
||||
// }
|
||||
bool jsonInput = false;
|
||||
};
|
||||
@@ -454,6 +455,9 @@ void parseArgs(int argc, char *argv[], RunConfig &runConfig) {
|
||||
runConfig.tashkeelModelPath = filesystem::path(argv[++i]);
|
||||
} else if (arg == "--json_input" || arg == "--json-input") {
|
||||
runConfig.jsonInput = true;
|
||||
} else if (arg == "--version") {
|
||||
std::cout << piper::getVersion() << std::endl;
|
||||
exit(0);
|
||||
} else if (arg == "--debug") {
|
||||
// Set DEBUG logging
|
||||
spdlog::set_level(spdlog::level::debug);
|
||||
|
||||
@@ -16,11 +16,24 @@
|
||||
|
||||
namespace piper {
|
||||
|
||||
#ifdef _PIPER_VERSION
|
||||
// https://stackoverflow.com/questions/47346133/how-to-use-a-define-inside-a-format-string
|
||||
#define _STR(x) #x
|
||||
#define STR(x) _STR(x)
|
||||
const std::string VERSION = STR(_PIPER_VERSION);
|
||||
#else
|
||||
const std::string VERSION = "";
|
||||
#endif
|
||||
|
||||
// Maximum value for 16-bit signed WAV sample
|
||||
const float MAX_WAV_VALUE = 32767.0f;
|
||||
|
||||
const std::string instanceName{"piper"};
|
||||
|
||||
std::string getVersion() {
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
// True if the string is a single UTF-8 codepoint
|
||||
bool isSingleCodepoint(std::string s) {
|
||||
return utf8::distance(s.begin(), s.end()) == 1;
|
||||
|
||||
@@ -89,6 +89,9 @@ struct Voice {
|
||||
ModelSession session;
|
||||
};
|
||||
|
||||
// Get version of Piper
|
||||
std::string getVersion();
|
||||
|
||||
// Must be called before using textTo* functions
|
||||
void initialize(PiperConfig &config);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user