2 Commits

Author SHA1 Message Date
6d23c1704f fix(audio): 移除 Resampler 测试代码并优化停滞检测
All checks were successful
ci/woodpecker/tag/woodpecker Pipeline was successful
通过测试确认 Resampler 和 WAV 解码正常工作,移除测试代码:
- 移除手动读取 Resampler 的测试代码(测试读取会破坏 Resampler 内部状态)
- 优化停滞检测逻辑:只有在已经开始播放后才报告停滞
- 修复语法错误(多余的闭合括号)

测试表明 Resampler 本身工作正常,数据读取成功。现在移除测试代码,
观察是否能正常播放完整音频。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 17:11:47 +08:00
b5f7c823c8 debug(audio): 添加 Resampler 数据读取测试
All checks were successful
ci/woodpecker/tag/woodpecker Pipeline was successful
为诊断 TTS 音频播放停滞问题,添加手动测试代码验证 Resampler 是否能正常读取音频数据:
- 在 speaker.Play() 前尝试从 Resampler 读取 10 个样本
- 打印读取状态和样本数据,验证数据流是否正常
- 重新创建 Resampler 确保测试不影响正常播放

此调试代码用于确认问题是在 Resampler/WAV 解码层,还是在 speaker/mixer 层

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 16:59:13 +08:00

View File

@@ -40,6 +40,7 @@ func PlayWav(c context.Context, r io.Reader) {
ctrl := &beep.Ctrl{Streamer: s} ctrl := &beep.Ctrl{Streamer: s}
done := make(chan struct{}) done := make(chan struct{})
speaker.Play(beep.Seq(ctrl, beep.Callback(func() { speaker.Play(beep.Seq(ctrl, beep.Callback(func() {
zap.S().Debugln("音频播放完成") zap.S().Debugln("音频播放完成")
close(done) close(done)
@@ -69,9 +70,9 @@ func PlayWav(c context.Context, r io.Reader) {
currentTime := float64(pos) / float64(format.SampleRate) currentTime := float64(pos) / float64(format.SampleRate)
zap.S().Debugf("播放进度: %d/%d (%.1f%%), %.2f秒", pos, totalSamples, progress, currentTime) zap.S().Debugf("播放进度: %d/%d (%.1f%%), %.2f秒", pos, totalSamples, progress, currentTime)
lastPos = pos lastPos = pos
} else { } else if lastPos > 0 {
zap.S().Debugf("播放停滞在位置: %d/%d, Streamer状态: %v", // 只有在已经开始播放后才报告停滞
pos, totalSamples, ctrl.Streamer != nil) zap.S().Debugf("播放停滞在位置: %d/%d", pos, totalSamples)
} }
} }
} }