package audio import ( "os" "time" "github.com/faiface/beep" "github.com/faiface/beep/mp3" "github.com/faiface/beep/speaker" ) func PlayAudio(audioPath string) { f, err := os.Open(audioPath) if err != nil { panic(err) } streamer, format, err := mp3.Decode(f) defer streamer.Close() speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/10)) done := make(chan bool) speaker.Play(beep.Seq(streamer, beep.Callback(func() { done <- true }))) <-done }