Skip to content

Commit f98e7b2

Browse files
committed
fix(pitch): add zero-phoneme defense and logging for CUBLAS debug
- PitchInference.cpp: log phoneme count/ph_dur shape/predictor input shapes; return explicit InferenceInputInvalid when phoneCount == 0 - InputWord.cpp (preprocessPhonemeDurations): return error on zero phonemes (protects all callers: Duration/Pitch/Variance/Acoustic) - ChainG2p TaskImpl: remove mode restriction on empty-pronunciation fallback — always fill missing pronunciation with original lyric - ChainG2p-Eng config: add missing langRef=eng/default so Multig2p receives a valid language prefix instead of empty string
1 parent ae97faf commit f98e7b2

4 files changed

Lines changed: 43 additions & 4 deletions

File tree

‎domains/ds-infer/lib/util/inferutil/src/InputWord.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ namespace ds::infer::inferutil {
9999
}
100100

101101
auto phoneCount = getPhoneCount(words);
102+
if (phoneCount == 0) {
103+
return srt::core::Error(srt::core::ErrorCode::InferenceInputInvalid,
104+
"preprocessPhonemeDurations: phoneme count is zero");
105+
}
106+
102107
using TensorType = int64_t;
103108
auto exp = TensorHelper<TensorType>::createFor1DArray(phoneCount);
104109
if (!exp) {

‎plugins/G2P/chain/internal/V1/TaskImpl.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ namespace srt::g2p::plugins::ChainG2p::Internal::V1 {
6060
res.mode = word.mode;
6161
res.errorType = word.errorType;
6262

63-
// copy 模式下,如果发音为空,应该原样返回
64-
if (res.mode == srt::g2p::kG2pModeCopy && res.pronunciation.empty()) {
63+
// 无论 mode 为何,pronunciation 不应为空;兜底使用原 lyric
64+
if (res.pronunciation.empty()) {
6565
res.pronunciation = res.lyric;
6666
if (res.candidates.empty()) {
6767
res.candidates = {res.lyric};

‎plugins/diffsinger/pitch/PitchInference.cpp‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,35 @@ namespace srt::svs {
329329
return exp.takeError();
330330
}
331331

332+
{
333+
auto phoneCount = ds::infer::inferutil::getPhoneCount(pitchInput->words);
334+
Log.srtInfo("%1 phoneme count = %2", kLogPrefix, phoneCount);
335+
for (size_t wi = 0; wi < pitchInput->words.size(); ++wi) {
336+
const auto &w = pitchInput->words[wi];
337+
Log.srtInfo("%1 word[%2] phones=%3 notes=%4", kLogPrefix, wi, w.phones.size(), w.notes.size());
338+
for (size_t pi = 0; pi < w.phones.size(); ++pi) {
339+
Log.srtInfo("%1 phone[%2] token='%3' lang='%4'", kLogPrefix, pi, w.phones[pi].token, w.phones[pi].language);
340+
}
341+
}
342+
if (phoneCount == 0) {
343+
setState(Failed);
344+
Log.srtCritical("%1 start: zero phonemes from G2P — cannot run pitch inference", kLogPrefix);
345+
return srt::core::Error::inferenceError(srt::core::ErrorCode::InferenceInputInvalid,
346+
"[Pitch] zero phonemes from G2P — cannot run pitch inference",
347+
{}, "pitch");
348+
}
349+
}
332350
if (auto exp = ds::infer::inferutil::preprocessPhonemeDurations(pitchInput->words,
333351
config->frameWidth);
334352
exp) {
335-
sessionInput->inputs.emplace("ph_dur", exp.take());
353+
auto phDur = exp.take();
354+
{
355+
auto shape = phDur->shape();
356+
std::string shapeStr;
357+
for (auto s : shape) shapeStr += std::to_string(s) + " ";
358+
Log.srtInfo("%1 ph_dur shape: [%2]", kLogPrefix, shapeStr);
359+
}
360+
sessionInput->inputs.emplace("ph_dur", std::move(phDur));
336361
} else {
337362
setState(Failed);
338363
Log.srtCritical("%1 start: preprocessPhonemeDurations failed: %2",
@@ -545,6 +570,15 @@ namespace srt::svs {
545570
{}, "pitch");
546571
}
547572

573+
// Log input tensor shapes before predictor inference
574+
Log.srtInfo("%1 predictor input keys:", kLogPrefix);
575+
for (const auto &[name, tensor] : sessionInput->inputs) {
576+
auto shape = tensor->shape();
577+
std::string shapeStr;
578+
for (auto s : shape) shapeStr += std::to_string(s) + " ";
579+
Log.srtInfo("%1 '%2' shape=[%3]", kLogPrefix, name, shapeStr);
580+
}
581+
548582
srt::core::NO<srt::core::TaskResult> sessionTaskResult;
549583
auto sessionExp = impl.predictorSession->start(sessionInput);
550584
if (!sessionExp) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"$version": "1.0", "level": 1, "mode": "standard", "schema": {}, "configuration": {"steps": [{"step": "tagAndValidate", "params": {"tagger": [{"type": "regex", "value": ["([A-Z]+)"], "tag": "uppercase", "action": "copy"}, {"type": "regex", "value": ["([a-z]+)"], "tag": "lowercase", "action": "convert"}]}}, {"step": "dict", "params": {"enabled": true, "file": "ds_cmudict-07b.txt"}}, {"step": "model", "params": {"enabled": true, "id": "g2p-multig2p-multi-official", "batchSize": 20}}, {"step": "fallback", "params": {"useOriginal": true, "markFailed": true}}]}}
1+
{"$version": "1.0", "level": 1, "mode": "standard", "schema": {}, "configuration": {"steps": [{"step": "tagAndValidate", "params": {"tagger": [{"type": "regex", "value": ["([A-Z]+)"], "tag": "uppercase", "action": "copy"}, {"type": "regex", "value": ["([a-z]+)"], "tag": "lowercase", "action": "convert"}]}}, {"step": "dict", "params": {"enabled": true, "file": "ds_cmudict-07b.txt"}}, {"step": "model", "params": {"enabled": true, "id": "g2p-multig2p-multi-official", "langRef": "eng/default", "batchSize": 20}}, {"step": "fallback", "params": {"useOriginal": true, "markFailed": true}}]}}

0 commit comments

Comments
 (0)