appid := "************"
apikey := "***********88"
curtime := strconv.FormatInt(time.Now().Unix(), 10)
param := make(map[string]string)
param["engine_type"] = "sms16k"
param["aue"] = "raw"
tt, _ := json.Marshal(param)
base64_param := base64.StdEncoding.EncodeToString(tt)
w := md5.New()
io.WriteString(w, apikey+curtime+base64_param)
checksum := fmt.Sprintf("%x", w.Sum(nil))
body, _ := ioutil.ReadFile("./ceshi.pcm")
base64_audio := base64.StdEncoding.EncodeToString(body)
data := url.Values{}
data.Add("audio", string(base64_audio))
res_body := data.Encode()
client := &http.Client{}
req, _ := http.NewRequest("POST", "http://api.xfyun.cn/v1/service/v1/iat", strings.NewReader(res_body))
req.Header.Set("X-Appid", appid)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("X-Param", base64_param)
req.Header.Set("X-CheckSum", checksum)
req.Header.Set("X-Curtime", curtime)
response, _ := client.Do(req)
defer response.Body.Close()
resp_body, _ := ioutil.ReadAll(response.Body)
fmt.Print(string(resp_body))
1