fix: 修复 TTS 音频后处理中的关键缺陷(int16 溢出 / padding_len=0 / 异常类型)#2753
Merged
RVC-Boss merged 1 commit intoRVC-Boss:mainfrom Apr 18, 2026
Merged
fix: 修复 TTS 音频后处理中的关键缺陷(int16 溢出 / padding_len=0 / 异常类型)#2753RVC-Boss merged 1 commit intoRVC-Boss:mainfrom
RVC-Boss merged 1 commit intoRVC-Boss:mainfrom
Conversation
1. 修复音频超采样时 int16 双重转换导致整数溢出(CRITICAL)
- audio_postprocess 中 `audio = (audio * 32768).astype(np.int16)` 位于
if/else 块之外无条件执行,当 super_sampling=True 时音频已在分支内
转为 int16,再次乘以 32768 导致溢出和音频完全失真
- 同时修复 super_sampling=True 但超分模型不存在时 torch.Tensor 调用
.astype() 的 AttributeError
2. 修复 batched vocoder 推理中 padding_len=0 导致音频丢失(HIGH)
- 当 padding_len 恰好为 0 时,`-0 * upsample_rate == 0`,切片
`audio[x:0]` 返回空张量,导致整段音频丢失
3. 修复文件不存在时错误地抛出 FileExistsError(LOW)
- 应为 FileNotFoundError
Made-with: Cursor
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.
问题描述
在
GPT_SoVITS/TTS_infer_pack/TTS.py的audio_postprocess方法中发现三个 bug:1. [CRITICAL] 音频超采样时 int16 双重转换导致整数溢出
第 1590 行
audio = (audio * 32768).astype(np.int16)位于if super_sampling / else块之外,无条件执行。当
super_sampling=True时:此外,当
super_sampling=True但超分模型文件不存在时,audio仍为torch.Tensor,调用
.astype()会抛出AttributeError。2. [HIGH] padding_len=0 时 batched vocoder 推理音频丢失
batched_decode方法中,当最后一个 chunk 刚好填满(padding_len == 0)时:-0 * upsample_rate == 0,切片变为audio[x:0],返回空张量,导致整段音频丢失。3. [LOW] 文件不存在时错误地抛出 FileExistsError
第 502 行在 LoRA 底模文件不存在时抛出
FileExistsError,应为FileNotFoundError。修改内容
padding_len == 0增加条件判断,避免空切片测试方案
super_sampling=True进行 TTS 推理,验证音频输出正常padding_len=0边界条件