Fix synthesis speaker id bug

This commit is contained in:
Michael Hansen
2023-01-10 14:01:47 -06:00
parent dfa03d80e6
commit a34b2d4f3b
3 changed files with 7 additions and 5 deletions

View File

@@ -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()));