Fix: handle empty bert_list and align BERT/phones length#2769
Open
c137650 wants to merge 1 commit intoRVC-Boss:mainfrom
Open
Fix: handle empty bert_list and align BERT/phones length#2769c137650 wants to merge 1 commit intoRVC-Boss:mainfrom
c137650 wants to merge 1 commit intoRVC-Boss:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 修改摘要
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.py→get_phones_and_bert()函数(第 602-632 行)