-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
132 lines (108 loc) · 2.91 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package ase
const (
StatusFirstFrame = 0
StatusContinue = 1
StatusLastFrame = 2
StatusForOnce = 3
)
type Request struct {
Header RequestHeader `json:"header,omitempty"`
Parameter map[string]interface{} `json:"parameter,omitempty"`
Payload map[string]interface{} `json:"payload,omitempty"`
}
type TextPayload struct {
Status int `json:"status"`
Text string `json:"text"`
}
type AudioPayload struct {
Encoding string `json:"encoding"`
SampleRate int `json:"sample_rate"`
Channels int `json:"channels"`
BitDepth int `json:"bit_depth"`
Status int `json:"status"`
Seq int `json:"seq"`
Audio string `json:"audio"`
FrameSize int `json:"frame_size"`
}
type ImagePayload struct {
Status int `json:"status"`
Image string `json:"image"`
}
//type VideoPayload struct {
// Status int `json:"status"`
//}
//
//type ResourcePayload struct {
// Status int `json:"status"`
//}
// RequestHeader 平台参数
type RequestHeader map[string]interface{}
func (h RequestHeader) Set(key, value string) {
h[key] = value
}
func (h RequestHeader) SetAppID(appid string) {
h["app_id"] = appid
}
func (h RequestHeader) SetStatus(status int) {
h["status"] = status
}
func (h RequestHeader) SetResID(resId string) {
h["res_id"] = resId
}
func (h RequestHeader) SetDirectEng(eng string) {
h["directEngIp"] = eng
}
func (req *Request) SetHeaders(headers RequestHeader) {
req.Header = headers
}
func (req *Request) SetParameter(key string, value interface{}) {
if req.Parameter == nil {
req.Parameter = make(map[string]interface{})
}
req.Parameter[key] = value
}
func (req *Request) SetParameters(params map[string]interface{}) {
req.Parameter = params
}
func (req *Request) SetTextPayload(key string, payload *TextPayload) {
if req.Payload == nil {
req.Payload = make(map[string]interface{})
}
req.Payload[key] = payload
}
func (req *Request) SetAudioPayload(key string, payload *AudioPayload) {
if req.Payload == nil {
req.Payload = make(map[string]interface{})
}
req.Payload[key] = payload
}
func (req *Request) SetImagePayload(key string, payload *ImagePayload) {
if req.Payload == nil {
req.Payload = make(map[string]interface{})
}
req.Payload[key] = payload
}
func (req *Request) SetPayload(key string, value interface{}) {
if req.Payload == nil {
req.Payload = make(map[string]interface{})
}
req.Payload[key] = value
}
func (req *Request) SetPayloads(payloads map[string]interface{}) {
req.Payload = payloads
}
type Resp struct {
Header *Header `json:"header"`
Payload interface{} `json:"payload"`
}
type Header struct {
Code int `json:"code"`
Message string `json:"message"`
Sid string `json:"sid"`
Status int `json:"status"`
}
type AIaaSRequest struct {
Common map[string]interface{} `json:"common,omitempty"`
Business map[string]interface{} `json:"business,omitempty"`
Data map[string]interface{} `json:"data,omitempty"`
}