From 2720b9e2d20004aa4dddbcfdef9209b7ea212e9c Mon Sep 17 00:00:00 2001 From: Junv Zhao Date: Tue, 27 Jun 2017 14:50:50 +0800 Subject: [PATCH] #5 Store the audio file in a temp folder --- main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index fa77747..ed2f35c 100644 --- a/main.go +++ b/main.go @@ -21,7 +21,7 @@ import ( ) const ( - Mp3FileName = "say-it.mp3" + Mp3FileName = "/tmp/say-it.mp3" ) var ( @@ -113,7 +113,7 @@ func fetchVoiceAndSpeak(text string) { // fmt.Println(response.StatusCode) defer response.Body.Close() - out, err := os.Create(Mp3FileName) + out, err := os.Create(utils.HomeDir() + Mp3FileName) if err != nil { log.Fatal("Create file failed:" + err.Error()) } @@ -124,7 +124,7 @@ func fetchVoiceAndSpeak(text string) { } func speak() { - command := exec.Command("afplay", Mp3FileName) + command := exec.Command("afplay", utils.HomeDir()+Mp3FileName) if err := command.Run(); err != nil { log.Error("Failed to say the words: " + err.Error()) }