mirror of
https://github.com/pstrueb/piper.git
synced 2026-05-04 21:18:01 +00:00
Load phoneme_silence from voice config
This commit is contained in:
@@ -189,7 +189,21 @@ int main(int argc, char *argv[]) {
|
||||
runConfig.sentenceSilenceSeconds.value();
|
||||
}
|
||||
|
||||
voice.synthesisConfig.phonemeSilenceSeconds = runConfig.phonemeSilenceSeconds;
|
||||
if (runConfig.phonemeSilenceSeconds) {
|
||||
if (!voice.synthesisConfig.phonemeSilenceSeconds) {
|
||||
// Overwrite
|
||||
voice.synthesisConfig.phonemeSilenceSeconds =
|
||||
runConfig.phonemeSilenceSeconds;
|
||||
} else {
|
||||
// Merge
|
||||
for (const auto &[phoneme, silenceSeconds] :
|
||||
*runConfig.phonemeSilenceSeconds) {
|
||||
voice.synthesisConfig.phonemeSilenceSeconds->try_emplace(
|
||||
phoneme, silenceSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
} // if phonemeSilenceSeconds
|
||||
|
||||
if (runConfig.outputType == OUTPUT_DIRECTORY) {
|
||||
runConfig.outputPath = filesystem::absolute(runConfig.outputPath.value());
|
||||
|
||||
@@ -140,7 +140,11 @@ void parseSynthesisConfig(json &configRoot, SynthesisConfig &synthesisConfig) {
|
||||
// "inference": {
|
||||
// "noise_scale": 0.667,
|
||||
// "length_scale": 1,
|
||||
// "noise_w": 0.8
|
||||
// "noise_w": 0.8,
|
||||
// "phoneme_silence": {
|
||||
// "<phoneme>": <seconds of silence>,
|
||||
// ...
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -166,7 +170,27 @@ void parseSynthesisConfig(json &configRoot, SynthesisConfig &synthesisConfig) {
|
||||
if (inferenceValue.contains("noise_w")) {
|
||||
synthesisConfig.noiseW = inferenceValue.value("noise_w", 0.8f);
|
||||
}
|
||||
}
|
||||
|
||||
if (inferenceValue.contains("phoneme_silence")) {
|
||||
// phoneme -> seconds of silence to add after
|
||||
synthesisConfig.phonemeSilenceSeconds.emplace();
|
||||
auto phonemeSilenceValue = inferenceValue["phoneme_silence"];
|
||||
for (auto &phonemeItem : phonemeSilenceValue.items()) {
|
||||
std::string phonemeStr = phonemeItem.key();
|
||||
if (!isSingleCodepoint(phonemeStr)) {
|
||||
spdlog::error("\"{}\" is not a single codepoint", phonemeStr);
|
||||
throw std::runtime_error(
|
||||
"Phonemes must be one codepoint (phoneme silence)");
|
||||
}
|
||||
|
||||
auto phoneme = getCodepoint(phonemeStr);
|
||||
(*synthesisConfig.phonemeSilenceSeconds)[phoneme] =
|
||||
phonemeItem.value().get<float>();
|
||||
}
|
||||
|
||||
} // if phoneme_silence
|
||||
|
||||
} // if inference
|
||||
|
||||
} /* parseSynthesisConfig */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user