diff --git a/pkg/audio/play.go b/pkg/audio/play.go index 62c3378..55af1b4 100644 --- a/pkg/audio/play.go +++ b/pkg/audio/play.go @@ -24,6 +24,7 @@ func init() { func PlayWav(c context.Context, r io.Reader) { streamer, format, err := wav.Decode(r) if err != nil { + zap.S().Errorln("WAV解码失败: ", err) return } defer streamer.Close() @@ -45,6 +46,7 @@ func PlayWav(c context.Context, r io.Reader) { speaker.Lock() ctrl.Streamer = nil speaker.Unlock() + return } } } @@ -53,6 +55,7 @@ func PlayWav(c context.Context, r io.Reader) { func PlayMP3(c context.Context, r io.ReadCloser) { streamer, format, err := mp3.Decode(r) if err != nil { + zap.S().Errorln("MP3解码失败: ", err) return } defer streamer.Close() @@ -74,6 +77,7 @@ func PlayMP3(c context.Context, r io.ReadCloser) { speaker.Lock() ctrl.Streamer = nil speaker.Unlock() + return } } } diff --git a/pkg/tts/aliyun.go b/pkg/tts/aliyun.go index 4e9ae61..a476d21 100644 --- a/pkg/tts/aliyun.go +++ b/pkg/tts/aliyun.go @@ -45,9 +45,11 @@ func (tts *AliTTS) Sound(text string) { if text == "" { return } + zap.S().Infof("开始播放TTS: %s", text) buf, err := tts.Get(text) if err == nil && buf != nil { audio.PlayWav(tts.ctx, buf) + zap.S().Infof("TTS播放完成: %s", text) } else { zap.S().Errorln("AliTTS 请求异常: ", err) }