whoops dont sleep use some ctx

master
Bel LaPointe 2023-03-27 06:19:39 -06:00
parent f649862dd4
commit a6a9b177e9
1 changed files with 4 additions and 1 deletions

View File

@ -68,6 +68,9 @@ func (v01 *V01) _tts(text string) error {
speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/30)) speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/30))
speaker.Play(&effects.Volume{Streamer: beep.ResampleRatio(4, 1, &beep.Ctrl{Streamer: beep.Loop(1, decoder)})}) speaker.Play(&effects.Volume{Streamer: beep.ResampleRatio(4, 1, &beep.Ctrl{Streamer: beep.Loop(1, decoder)})})
duration := time.Duration(decoder.Len()) * format.SampleRate.D(1) duration := time.Duration(decoder.Len()) * format.SampleRate.D(1)
time.Sleep(duration) select {
case <-v01.ctx.Done():
case <-time.After(duration):
}
return nil return nil
} }