Created
November 30, 2023 13:44
-
-
Save wuriyanto48/81b286ec7d555e023a8118227f2dc76b to your computer and use it in GitHub Desktop.
Google Text To Speech
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 ( | |
"fmt" | |
"io" | |
"net/http" | |
"net/url" | |
"os" | |
) | |
func main() { | |
text := "nomor antrian 10, ke loket 6" | |
url := fmt.Sprintf("http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=%s&tl=%s", url.QueryEscape(text), "id") | |
resp, err := http.Get(url) | |
if err != nil { | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
fmt.Println(resp.Header) | |
defer func() { resp.Body.Close() }() | |
out, err := os.Create("out.wav") | |
if err != nil { | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
defer func() { out.Close() }() | |
io.Copy(out, resp.Body) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment