Add --version

This commit is contained in:
Michael Hansen
2023-07-10 15:09:58 -05:00
parent 42d14ef21f
commit daf6e7fcf7
6 changed files with 77 additions and 25 deletions
+1
View File
@@ -1,6 +1,7 @@
.PHONY: piper clean
LIB_DIR := lib/Linux-$(shell uname -m)
VERSION := $(cat VERSION)
piper:
mkdir -p build
+50 -23
View File
@@ -18,30 +18,31 @@ Voices are trained with [VITS](https://github.com/jaywalnut310/vits/) and export
Our goal is to support Home Assistant and the [Year of Voice](https://www.home-assistant.io/blog/2022/12/20/year-of-voice/).
[Download voices](https://github.com/rhasspy/piper/releases/tag/v0.0.2) for the supported languages:
[Download voices](https://huggingface.co/rhasspy/piper-voices/tree/main) for the supported languages:
* Catalan (ca)
* Danish (da)
* German (de)
* British English (en-gb)
* U.S. English (en-us)
* Spanish (es)
* Finnish (fi)
* French (fr)
* Greek (el-gr)
* Icelandic (is)
* Italian (it)
* Kazakh (kk)
* Nepali (ne)
* Dutch (nl)
* Norwegian (no)
* Polish (pl)
* Brazilian Portuguese (pt-br)
* Russian (ru)
* Swedish (sv-se)
* Ukrainian (uk)
* Vietnamese (vi)
* Chinese (zh-cn)
* Catalan (ca_ES)
* Danish (da_DK)
* German (de_DE)
* English (en_GB, en_US)
* Spanish (es_ES, es_MX)
* Finnish (fi_FI)
* French (fr_FR)
* Greek (el_GR)
* Icelandic (is_IS)
* Italian (it_IT)
* Georgian (ka_GE)
* Kazakh (kk_KZ)
* Nepali (ne_NP)
* Dutch (nl_BE, nl_NL)
* Norwegian (no_NO)
* Polish (pl_PL)
* Portuguese (pt_BR)
* Russian (ru_RU)
* Swedish (sv_SE)
* Swahili (sw_CD)
* Ukrainian (uk_UA)
* Vietnamese (vi_VN)
* Chinese (zh_CN)
## Installation
@@ -74,6 +75,32 @@ For multi-speaker models, use `--speaker <number>` to change speakers (default:
See `piper --help` for more options.
### JSON Input
The `piper` executable can accept JSON input when using the `--json-input` flag. Each line of input must be a JSON object with `text` field. For example:
``` json
{ "text": "First sentence to speak." }
{ "text": "Second sentence to speak." }
```
Optional fields include:
* `speaker` - string
* Name of the speaker to use from `speaker_id_map` in config (multi-speaker voices only)
* `speaker_id` - number
* Id of speaker to use from 0 to number of speakers - 1 (multi-speaker voices only, overrides "speaker")
* `output_file` - string
* Path to output WAV file
The following example writes two sentences with different speakers to different files:
``` json
{ "text": "First speaker.", "speaker_id": 0, "output_file": "/tmp/speaker_0.wav" }
{ "text": "Second speaker.", "speaker_id": 1, "output_file": "/tmp/speaker_1.wav" }
```
## People using Piper
Piper has been used in the following projects/papers:
+4
View File
@@ -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})
+6 -2
View File
@@ -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);
+13
View File
@@ -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;
+3
View File
@@ -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);