Created
May 12, 2020 07:35
-
-
Save yakutozcan/2a16b51b0077e1e68ca521b11acf9c6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/faiface/beep/wav" | |
"log" | |
"os" | |
"time" | |
"github.com/faiface/beep" | |
"github.com/faiface/beep/speaker" | |
) | |
func main() { | |
f, err := os.Open(os.Args[1]) | |
if err != nil { | |
log.Fatal(err) | |
} | |
streamer, format, err := wav.Decode(f) | |
if err != nil { | |
log.Fatal(err) | |
} | |
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment