优化逻辑

This commit is contained in:
2025-03-13 19:18:10 +08:00
parent 7a07f39f1b
commit 4189705922
14 changed files with 185 additions and 37 deletions

View File

@@ -7,7 +7,6 @@ import (
"game-driver/pkg/audio"
"game-driver/pkg/tts"
"go.uber.org/zap"
"time"
)
func TTS(item schema.WaitItemModel) func(c context.Context) error {
@@ -20,13 +19,8 @@ func TTS(item schema.WaitItemModel) func(c context.Context) error {
zap.S().Infoln("播放待机 TTS 语音")
defer zap.S().Infoln("结束待机 TTS 语音")
for {
audio.PlayWav(c, reader)
select {
case <-c.Done():
return nil
case <-time.After(time.Duration(item.Interval) * time.Second):
}
}
audio.PlayWav(c, reader)
return nil
}
}