You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
voicebot/icshttpclient/client_test.go

48 lines
1.1 KiB
Go

3 years ago
package icshttpclient
import (
"bytes"
"encoding/json"
"fmt"
"testing"
)
type TTSParam struct {
Text string
Speaker_Name string
Pause float32
Speed float32
}
func TestClient(t *testing.T) {
c := NewIcsHttpClient("GET", "http://192.168.0.21:8080/tts/1", nil)
resp, err := c.Do(c.Request)
if err != nil {
t.Fatal(err)
} else {
defer resp.Body.Close()
fmt.Println(resp)
body := make([]byte, resp.ContentLength)
resp.Body.Read(body)
fmt.Println("==================\n", string(body))
}
param := TTSParam{"동해물과 백두산이", "voice_name", 1.1, 1.2}
p, _ := json.Marshal(param)
p1 := bytes.NewBuffer(p)
c1 := NewIcsHttpClient("POST", "http://192.168.0.21:8080/tts/3", p1)
c1.Request.Header.Add("apiKey", "aaabbb-cccddd-1234567890")
c1.Request.Header.Add("Content-Tpe", "application/json")
c1.Request.ParseForm()
resp1, err1 := c1.Do(c1.Request)
if err1 != nil {
t.Fatal(err1)
} else {
defer resp1.Body.Close()
fmt.Println(resp1.StatusCode, resp1)
body := make([]byte, resp1.ContentLength)
resp1.Body.Read(body)
fmt.Println("==================\n", string(body))
}
}