27 lines
492 B
Go
27 lines
492 B
Go
package middleware
|
|
|
|
import (
|
|
"game-driver/internal/schema"
|
|
"game-driver/leaf"
|
|
"game-driver/pkg/tts"
|
|
)
|
|
|
|
// SoundStart 开始词播报
|
|
func SoundStart(t *tts.AliTTS) leaf.HandlerFunc {
|
|
return func(c *leaf.Context) {
|
|
pm := leaf.Value[*schema.PlayModal](c, PayloadJSONKey)
|
|
t.Sound(pm.TTS.Start)
|
|
|
|
defer func() {
|
|
switch leaf.Value[leaf.EndType](c, leaf.EndKey) {
|
|
case leaf.EndTimer:
|
|
t.Sound(pm.TTS.End)
|
|
case leaf.EndStop:
|
|
t.Sound(pm.TTS.Stop)
|
|
}
|
|
}()
|
|
|
|
c.Next()
|
|
}
|
|
}
|