|
15 | 15 | *
|
16 | 16 | */
|
17 | 17 |
|
18 |
| -using FullSerializer; |
19 | 18 | using IBM.Watson.DeveloperCloud.Connection;
|
20 | 19 | using IBM.Watson.DeveloperCloud.DataTypes;
|
21 | 20 | using IBM.Watson.DeveloperCloud.Logging;
|
22 | 21 | using IBM.Watson.DeveloperCloud.Services.Assistant.v1;
|
23 | 22 | using IBM.Watson.DeveloperCloud.Services.SpeechToText.v1;
|
24 | 23 | using IBM.Watson.DeveloperCloud.Utilities;
|
25 |
| -using System; |
26 | 24 | using System.Collections;
|
27 | 25 | using System.Collections.Generic;
|
28 | 26 | using UnityEngine;
|
@@ -64,43 +62,43 @@ void Start()
|
64 | 62 | LogSystem.InstallDefaultReactors();
|
65 | 63 |
|
66 | 64 |
|
67 |
| - //#region http custom headers |
68 |
| - //// Create credential and instantiate Assistant service |
69 |
| - //Credentials assistantCredentials = new Credentials(_assistantUsername, _assistantPassword, _assistantUrl); |
70 |
| - |
71 |
| - //_assistant = new Assistant(assistantCredentials); |
72 |
| - //_assistant.VersionDate = _assistantVersionDate; |
73 |
| - |
74 |
| - //Dictionary<string, object> input = new Dictionary<string, object>(); |
75 |
| - //input.Add("text", _inputString); |
76 |
| - //MessageRequest messageRequest = new MessageRequest() |
77 |
| - //{ |
78 |
| - // Input = input, |
79 |
| - // AlternateIntents = true |
80 |
| - //}; |
81 |
| - |
82 |
| - //// Create customData object |
83 |
| - //Dictionary<string, object> assistantCustomData = new Dictionary<string, object>(); |
84 |
| - //// Create a dictionary of custom headers |
85 |
| - //Dictionary<string, string> assistantCustomHeaders = new Dictionary<string, string>(); |
86 |
| - //// Add to the header dictionary |
87 |
| - //assistantCustomHeaders.Add("X-Watson-Metadata", "customer_id=some-assistant-customer-id"); |
88 |
| - //// Add the header dictionary to the custom data object |
89 |
| - //assistantCustomData.Add(Constants.String.CUSTOM_REQUEST_HEADERS, assistantCustomHeaders); |
90 |
| - |
91 |
| - //// Logging what we will send |
92 |
| - //if (assistantCustomData.ContainsKey(Constants.String.CUSTOM_REQUEST_HEADERS)) |
93 |
| - //{ |
94 |
| - // Log.Debug("ExampleCustomHeader.Start()", "Assistant custom request headers:"); |
95 |
| - // foreach (KeyValuePair<string, string> kvp in assistantCustomData[Constants.String.CUSTOM_REQUEST_HEADERS] as Dictionary<string, string>) |
96 |
| - // { |
97 |
| - // Log.Debug("ExampleCustomHeader.Start()", "\t{0}: {1}", kvp.Key, kvp.Value); |
98 |
| - // } |
99 |
| - //} |
100 |
| - |
101 |
| - //// Call service using custom data object |
102 |
| - //_assistant.Message(OnMessage, OnFail, _assistantWorkspaceId, messageRequest, customData: assistantCustomData); |
103 |
| - //#endregion |
| 65 | + #region http custom headers |
| 66 | + // Create credential and instantiate Assistant service |
| 67 | + Credentials assistantCredentials = new Credentials(_assistantUsername, _assistantPassword, _assistantUrl); |
| 68 | + |
| 69 | + _assistant = new Assistant(assistantCredentials); |
| 70 | + _assistant.VersionDate = _assistantVersionDate; |
| 71 | + |
| 72 | + Dictionary<string, object> input = new Dictionary<string, object>(); |
| 73 | + input.Add("text", _inputString); |
| 74 | + MessageRequest messageRequest = new MessageRequest() |
| 75 | + { |
| 76 | + Input = input, |
| 77 | + AlternateIntents = true |
| 78 | + }; |
| 79 | + |
| 80 | + // Create customData object |
| 81 | + Dictionary<string, object> assistantCustomData = new Dictionary<string, object>(); |
| 82 | + // Create a dictionary of custom headers |
| 83 | + Dictionary<string, string> assistantCustomHeaders = new Dictionary<string, string>(); |
| 84 | + // Add to the header dictionary |
| 85 | + assistantCustomHeaders.Add("X-Watson-Metadata", "customer_id=some-assistant-customer-id"); |
| 86 | + // Add the header dictionary to the custom data object |
| 87 | + assistantCustomData.Add(Constants.String.CUSTOM_REQUEST_HEADERS, assistantCustomHeaders); |
| 88 | + |
| 89 | + // Logging what we will send |
| 90 | + if (assistantCustomData.ContainsKey(Constants.String.CUSTOM_REQUEST_HEADERS)) |
| 91 | + { |
| 92 | + Log.Debug("ExampleCustomHeader.Start()", "Assistant custom request headers:"); |
| 93 | + foreach (KeyValuePair<string, string> kvp in assistantCustomData[Constants.String.CUSTOM_REQUEST_HEADERS] as Dictionary<string, string>) |
| 94 | + { |
| 95 | + Log.Debug("ExampleCustomHeader.Start()", "\t{0}: {1}", kvp.Key, kvp.Value); |
| 96 | + } |
| 97 | + } |
| 98 | + |
| 99 | + // Call service using custom data object |
| 100 | + _assistant.Message(OnMessage, OnFail, _assistantWorkspaceId, messageRequest, customData: assistantCustomData); |
| 101 | + #endregion |
104 | 102 |
|
105 | 103 | #region websocket custom headers
|
106 | 104 | // Websocket custom headers
|
@@ -128,8 +126,7 @@ void Start()
|
128 | 126 | }
|
129 | 127 | }
|
130 | 128 |
|
131 |
| - // Call service using custom data object |
132 |
| - //_speechToText.StartListening(OnRecognize, customData: speechToTextCustomData); |
| 129 | + // Call service using custom data object (see Active) |
133 | 130 | Active = true;
|
134 | 131 |
|
135 | 132 | StartRecording();
|
|
0 commit comments