Skip to content

Fix: handle empty bert_list and align BERT/phones length#2769

Open
c137650 wants to merge 1 commit intoRVC-Boss:mainfrom
c137650:fix/bert-length-mismatch
Open

Fix: handle empty bert_list and align BERT/phones length#2769
c137650 wants to merge 1 commit intoRVC-Boss:mainfrom
c137650:fix/bert-length-mismatch

Conversation

@c137650
Copy link
Copy Markdown

@c137650 c137650 commented Apr 19, 2026

📋 修改摘要
Bug 1:torch.cat() 空列表崩溃
错误信息:
RuntimeError: torch.cat(): expected a non-empty list of Tensors

根因:当 LangSegmenter.getTexts() 对某些文本返回空结果时,bert_list 变为空列表,导致 torch.cat([]) 崩溃。

修复:在调用 torch.cat() 前检查 bert_list 是否为空,若为空则创建零张量作为降级处理。
Bug 2:BERT 特征与 Phones 长度不匹配
错误信息:
RuntimeError: The size of tensor a (44) must match the size of tensor b (45)
at non-singleton dimension 1

根因:BERT 特征序列长度与音素(phones)序列长度不一致(如 BERT 返回 45 个特征,但 phones 只有 44 个)。

修复:在返回前检测长度差异,使用线性插值放大或裁剪对齐。
修改位置
api.pyget_phones_and_bert() 函数(第 602-632 行)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant