mirror of
https://github.com/pstrueb/piper.git
synced 2026-04-23 00:04:49 +00:00
Fix synthesis speaker id bug
This commit is contained in:
@@ -188,7 +188,7 @@ void parseArgs(int argc, char *argv[], RunConfig &runConfig) {
|
||||
runConfig.outputPath = filesystem::path(argv[++i]);
|
||||
} else if (arg == "-s" || arg == "--speaker") {
|
||||
ensureArg(argc, argv, i);
|
||||
runConfig.speakerId = (larynx::SpeakerId)stoll(argv[++i]);
|
||||
runConfig.speakerId = (larynx::SpeakerId)stoi(argv[++i]);
|
||||
} else if (arg == "-h" || arg == "--help") {
|
||||
printUsage(argv);
|
||||
exit(0);
|
||||
|
||||
@@ -53,10 +53,12 @@ void synthesize(SynthesisConfig &synthesisConfig, ModelSession &session,
|
||||
Ort::Value::CreateTensor<float>(memoryInfo, scales.data(), scales.size(),
|
||||
scalesShape.data(), scalesShape.size()));
|
||||
|
||||
// Add speaker id.
|
||||
// NOTE: These must be kept outside the "if" below to avoid being deallocated.
|
||||
vector<int64_t> speakerId{(int64_t)synthesisConfig.speakerId.value_or(0)};
|
||||
vector<int64_t> speakerIdShape{(int64_t)speakerId.size()};
|
||||
|
||||
if (synthesisConfig.speakerId) {
|
||||
// Add speaker id
|
||||
vector<int64_t> speakerId{(int64_t)synthesisConfig.speakerId.value()};
|
||||
vector<int64_t> speakerIdShape{(int64_t)speakerId.size()};
|
||||
inputTensors.push_back(Ort::Value::CreateTensor<int64_t>(
|
||||
memoryInfo, speakerId.data(), speakerId.size(), speakerIdShape.data(),
|
||||
speakerIdShape.size()));
|
||||
|
||||
@@ -27,7 +27,7 @@ struct WavHeader {
|
||||
|
||||
// Write WAV file header only
|
||||
void writeWavHeader(int sampleRate, int sampleWidth, int channels,
|
||||
uint32_t numSamples, ostream &audioFile) {
|
||||
uint32_t numSamples, std::ostream &audioFile) {
|
||||
WavHeader header;
|
||||
header.chunkSize = numSamples + sizeof(WavHeader) - 8;
|
||||
header.sampleRate = sampleRate;
|
||||
|
||||
Reference in New Issue
Block a user