/
JsonData.cs
297 lines (270 loc) · 6.49 KB
/
JsonData.cs
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
using System;
using System.Collections.Generic;
namespace JsonData
{
/*
"queryParams": {
object (QueryParameters)
},
"queryInput": {
object (QueryInput)
},
"inputAudio": string
}*/
//https://dialogflow.com/docs/reference/api-v2/rest/v2beta1/projects.agent.sessions/detectIntent
//https://dialogflow.com/docs/reference/api-v2/rest/v2/projects.agent.sessions/detectIntent#QueryParameters
[Serializable]
public class RequestBody
{
public QueryInput queryInput;
/*
string (bytes format)
Optional.
The natural language speech audio to be processed.
This field should be populated if queryInput is set to an input audio config.
A single request can contain up to 1 minute of speech audio data.
A base64-encoded string.
*/
public string inputAudio;
}
/*
* Required request body
* queryInput
* Represents the query input. It can contain either:
* 1.An audio config which instructs the speech recognizer how to process the speech audio.
* 2.A conversational query in the form of text,.
* 3.An event that specifies which intent to trigger.
* JSON representation
{
// Union field input can be only one of the following:
"audioConfig": {
object(InputAudioConfig)
},
"text": {
object(TextInput)
},
"event": {
object(EventInput)
}
// End of list of possible types for union field input.
}*/
[Serializable]
public class QueryInput
{
//public TextInput text;
public InputAudioConfig audioConfig;
}
/*
* InputAudioConfig
* Instructs the speech recognizer how to process the audio content.
{
"audioEncoding": enum(AudioEncoding),
"sampleRateHertz": number,
"languageCode": string,
"phraseHints": [
string
]
}
* phraseHints - is optional
*/
[Serializable]
public class InputAudioConfig
{
public AudioEncoding audioEncoding;
public int sampleRateHertz;
public String languageCode;
public String[] phraseHints;
}
/*AudioEncoding
* Audio encoding of the audio content sent in the conversational query request.
* Refer to the Cloud Speech API documentation for more details.
*/
[Serializable]
public enum AudioEncoding
{
AUDIO_ENCODING_UNSPECIFIED,
AUDIO_ENCODING_LINEAR_16,
AUDIO_ENCODING_FLAC,
AUDIO_ENCODING_MULAW,
AUDIO_ENCODING_AMR,
AUDIO_ENCODING_AMR_WB,
AUDIO_ENCODING_OGG_OPUS,
AUDIO_ENCODING_SPEEX_WITH_HEADER_BYTE
}
//https://dialogflow.com/docs/reference/api-v2/rest/Shared.Types/WebhookState
[Serializable]
public enum WebhookState
{
STATE_UNSPECIFIED,
WEBHOOK_STATE_ENABLED,
WEBHOOK_STATE_ENABLED_FOR_SLOT_FILLING
}
/*
* TextInput
* Represents the natural language text to be processed.
* {
"text": string,
"languageCode": string
}*/
[Serializable]
public class TextInput
{
public String text;
public String languageCode;
}
/*response body json doc
* {
"responseId": string,
"queryResult": {
object(QueryResult)
},
"webhookStatus": {
object(Status)
}
}
*/
[Serializable]
public class ResponseBody
{
public string responseId;
public QueryResult queryResult;
public Status webhookStatus;
}
//https://dialogflow.com/docs/reference/api-v2/rest/Shared.Types/QueryResult
/*{
"queryText": string,
"languageCode": string,
"speechRecognitionConfidence": number,
"action": string,
"parameters": {
object
},
"allRequiredParamsPresent": boolean,
"fulfillmentText": string,
"fulfillmentMessages": [
{
object(Message)
}
],
"webhookSource": string,
"webhookPayload": {
object
},
"outputContexts": [
{
object(Context)
}
],
"intent": {
object(Intent)
},
"intentDetectionConfidence": number,
"diagnosticInfo": {
object
}}*/
[Serializable]
public class QueryResult
{
public string queryText;
public string languageCode;
public int speechRecognitionConfidence;
public string action;
public Struct parameters;
public bool allRequiredParamsPresent;
public string fulfillmentText;
public Message[] fulfillmentMessages;
public string webhookSource;
public Struct webhookPayload;
public Context[] outputContexts;
public Intent intent;
public int intentDetectionConfidence;
public Struct diagnosticInfo;
}
//https://dialogflow.com/docs/reference/api-v2/rest/Shared.Types/Operation#Status.SCHEMA_REPRESENTATION
/*{
"code": number,
"message": string,
"details": [
{
"@type": string,
field1: ...,
...
}
]
}*/
[Serializable]
public class Status
{
public int code;
public string message;
public Object[] details;
}
//https://dialogflow.com/docs/reference/api-v2/rest/Shared.Types/Intent#SCHEMA_REPRESENTATION
[Serializable]
public class Intent
{
public string name;
public string displayName;
public WebhookState webhookState;
public int priority;
public bool isFallback;
}
//https://dialogflow.com/docs/reference/api-v2/rest/Shared.Types/Context
[Serializable]
public class Context
{
public string name;
}
[Serializable]
public class Struct
{
public Dictionary<string, Value> fields;
}
[Serializable]
public class Value
{
public NullValue null_value;
public double number_value;
public string string_value;
public bool bool_value;
public Struct struct_value;
public ListValue list_value;
public void ForBool(bool value){
this.bool_value = value;
}
public void ForString(string value)
{
this.string_value = value;
}
public void ForNumber(double number){
this.number_value = number;
}
public void ForNull()
{
this.null_value = NullValue.null_vaule;
}
public void ForStruct(Struct value){
this.struct_value = value;
}
public void ForList(ListValue value){
this.list_value = value;
}
}
[Serializable]
public enum NullValue
{
null_vaule
}
[Serializable]
public class ListValue{
public Value values;
}
[Serializable]
public class Text{
public string[] text;
}
[Serializable]
public class Message{
public Text text;
}
}