Skip to content

Commit ababa11

Browse files
authored
Merge pull request #304 from watson-developer-cloud/master
Pull release changes from Master
2 parents 99d175a + 44f7319 commit ababa11

File tree

13 files changed

+391
-133
lines changed

13 files changed

+391
-133
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
Change Log
22
==========
3+
## Version 2.0.0
4+
_2017-11-20_ MAJOR RELEASE, BREAKING CHANGES
5+
* New: Implemented error callbacks in each call
6+
* New: Implemented generic type success callbacks
7+
* New: Implemented `Dictionary<string, object>` to hold custom data for each call
8+
* New: Support for `Hololens`
9+
* New: Abstracted custom acoustic models for `SpeechToText`
10+
* New: Addition of streaming example where the sample is split up to improve latency
11+
* New: Transition to dll for `WebSocketSharp`
12+
* New: Added support for decoding unicode characters in `TextToSpeech`
13+
* Fixed: Transition `Delete` methods to `UnityWebRequest`
14+
* Fixed: Improvements to `SpeechToText` streaming
15+
* Fixed: `SpeechToText` streaming parameters
16+
* Fixed: Improvements to `ExampleStreaming`
17+
* Fixed: `SpeechToText` custom corpus
18+
* Fixed: Allow empty string to be sent when invoking `Message` from the `Conversation` service
19+
* Fixed: Standardized `Debug.Log` output throughout SDK
20+
* Fixed: Fix all integration tests
21+
322
## Version 1.0.0
423
_2017-08-31_ MAJOR RELEASE, BREAKING CHANGES
524

Docs/UnitySDK.shfbproj

Lines changed: 221 additions & 0 deletions
Large diffs are not rendered by default.

Docs/UnitySDK.shfbproj.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Docs/Watson Unity SDK.odg

15.7 KB
Binary file not shown.

Docs/Watson Unity SDK.odg.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "Watson Developer Cloud Unity SDK"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 1.0.0
41+
PROJECT_NUMBER = 2.0.0
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

Examples/ServiceExamples/Scripts/ExampleStreamingSplitSamples.cs

Lines changed: 87 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,26 @@
2424
using System.Collections.Generic;
2525
using UnityEngine.UI;
2626

27+
/// <summary>
28+
/// This class is an example of how to stream audio from the device microphone to the Speech to Text service in Unity.
29+
/// </summary>
2730
public class ExampleStreamingSplitSamples : MonoBehaviour
2831
{
2932
private string _username = null;
3033
private string _password = null;
3134
private string _url = null;
3235

36+
/// <summary>
37+
/// Text field to display the results of streaming.
38+
/// </summary>
3339
public Text ResultsField;
3440

3541
private int _recordingRoutine = 0;
3642
private string _microphoneID = null;
3743
private AudioClip _recording = null;
3844
private int _recordingBufferSize = 1;
3945
private int _recordingHZ = 22050;
40-
private int _sampleSegments = 50;
46+
private int _sampleSegments = 50;
4147

4248
private SpeechToText _speechToText;
4349

@@ -54,6 +60,9 @@ void Start()
5460
StartRecording();
5561
}
5662

63+
/// <summary>
64+
/// Gets or sets the Active state.
65+
/// </summary>
5766
public bool Active
5867
{
5968
get { return _speechToText.IsListening; }
@@ -105,12 +114,12 @@ private void OnError(string error)
105114
{
106115
Active = false;
107116

108-
Log.Debug("ExampleStreamingSplitSamples.OnError()", "Error! {0}", error);
117+
Log.Debug("ExampleStreamingSplitSamples.OnError()", "Error! {0}", error);
109118
}
110119

111120
private IEnumerator RecordingHandler()
112121
{
113-
Log.Debug("ExampleStreamingSplitSamples.RecordingHandler()", "devices: {0}", Microphone.devices);
122+
Log.Debug("ExampleStreamingSplitSamples.RecordingHandler()", "devices: {0}", Microphone.devices);
114123
// Start recording
115124
_recording = Microphone.Start(_microphoneID, true, _recordingBufferSize, _recordingHZ);
116125
yield return null;
@@ -127,82 +136,82 @@ private IEnumerator RecordingHandler()
127136
#endif
128137

129138
// Current sample segment number
130-
int sampleSegmentNum = 0;
139+
int sampleSegmentNum = 0;
131140

132141
// Size of the sample segment in samples
133-
int sampleSegmentSize = _recording.samples / _sampleSegments;
142+
int sampleSegmentSize = _recording.samples / _sampleSegments;
134143

135144
// Init samples
136145
float[] samples = null;
137146

138-
while (_recordingRoutine != 0 && _recording != null)
139-
{
140-
// Get the mic position
141-
int microphonePosition = Microphone.GetPosition(_microphoneID);
142-
if (microphonePosition > _recording.samples || !Microphone.IsRecording(_microphoneID))
143-
{
144-
Log.Error("ExampleStreamingSplitSamples.RecordingHandler()", "Microphone disconnected.");
145-
146-
StopRecording();
147-
yield break;
148-
}
149-
150-
int sampleStart = sampleSegmentSize * sampleSegmentNum;
151-
int sampleEnd = sampleSegmentSize * (sampleSegmentNum + 1);
152-
153-
#if ENABLE_DEBUGGING
154-
Log.Debug("ExampleStreamingSplitSamples.RecordinHandler", "microphonePosition: {0} | sampleStart: {1} | sampleEnd: {2} | sampleSegmentNum: {3}",
155-
microphonePosition.ToString(),
156-
sampleStart.ToString(),
157-
sampleEnd.ToString(),
158-
sampleSegmentNum.ToString());
159-
#endif
160-
//If the write position is past the end of the sample segment or if write position is before the start of the sample segment
161-
while (microphonePosition > sampleEnd || microphonePosition < sampleStart)
162-
{
163-
// Init samples
164-
samples = new float[sampleSegmentSize];
165-
// Write data from recording into samples starting from the sampleSegmentStart
166-
_recording.GetData(samples, sampleStart);
167-
168-
// Create AudioData and use the samples we just created
169-
AudioData record = new AudioData();
170-
record.MaxLevel = Mathf.Max(Mathf.Abs(Mathf.Min(samples)), Mathf.Max(samples));
171-
record.Clip = AudioClip.Create("Recording", sampleSegmentSize, _recording.channels, _recordingHZ, false);
172-
record.Clip.SetData(samples, 0);
173-
174-
// Send the newly created AudioData to the service
175-
_speechToText.OnListen(record);
176-
177-
// Iterate or reset sampleSegmentNum
178-
if (sampleSegmentNum < _sampleSegments - 1)
179-
{
180-
sampleSegmentNum++;
181-
#if ENABLE_DEBUGGING
182-
Log.Debug("ExampleStreamingSplitSamples.RecordingHandler()", "Iterating sampleSegmentNum: {0}", sampleSegmentNum);
183-
#endif
184-
}
185-
else
186-
{
187-
sampleSegmentNum = 0;
188-
#if ENABLE_DEBUGGING
189-
Log.Debug("ExampleStreamingSplitSamples.RecordingHandler()", "Resetting sampleSegmentNum: {0}", sampleSegmentNum);
190-
#endif
191-
}
192-
193-
#if ENABLE_TIME_LOGGING
194-
Log.Debug("ExampleStreamingSplitSamples.RecordingHandler", "Sending data - time since last transmission: {0} ms", Mathf.Floor((float)(DateTime.Now - now).TotalMilliseconds));
195-
now = DateTime.Now;
196-
#endif
197-
sampleStart = sampleSegmentSize * sampleSegmentNum;
198-
sampleEnd = sampleSegmentSize * (sampleSegmentNum + 1);
199-
}
200-
201-
yield return 0;
202-
}
203-
204-
yield break;
205-
}
147+
while (_recordingRoutine != 0 && _recording != null)
148+
{
149+
// Get the mic position
150+
int microphonePosition = Microphone.GetPosition(_microphoneID);
151+
if (microphonePosition > _recording.samples || !Microphone.IsRecording(_microphoneID))
152+
{
153+
Log.Error("ExampleStreamingSplitSamples.RecordingHandler()", "Microphone disconnected.");
154+
155+
StopRecording();
156+
yield break;
157+
}
158+
159+
int sampleStart = sampleSegmentSize * sampleSegmentNum;
160+
int sampleEnd = sampleSegmentSize * (sampleSegmentNum + 1);
161+
162+
#if ENABLE_DEBUGGING
163+
Log.Debug("ExampleStreamingSplitSamples.RecordinHandler", "microphonePosition: {0} | sampleStart: {1} | sampleEnd: {2} | sampleSegmentNum: {3}",
164+
microphonePosition.ToString(),
165+
sampleStart.ToString(),
166+
sampleEnd.ToString(),
167+
sampleSegmentNum.ToString());
168+
#endif
169+
//If the write position is past the end of the sample segment or if write position is before the start of the sample segment
170+
while (microphonePosition > sampleEnd || microphonePosition < sampleStart)
171+
{
172+
// Init samples
173+
samples = new float[sampleSegmentSize];
174+
// Write data from recording into samples starting from the sampleSegmentStart
175+
_recording.GetData(samples, sampleStart);
176+
177+
// Create AudioData and use the samples we just created
178+
AudioData record = new AudioData();
179+
record.MaxLevel = Mathf.Max(Mathf.Abs(Mathf.Min(samples)), Mathf.Max(samples));
180+
record.Clip = AudioClip.Create("Recording", sampleSegmentSize, _recording.channels, _recordingHZ, false);
181+
record.Clip.SetData(samples, 0);
182+
183+
// Send the newly created AudioData to the service
184+
_speechToText.OnListen(record);
185+
186+
// Iterate or reset sampleSegmentNum
187+
if (sampleSegmentNum < _sampleSegments - 1)
188+
{
189+
sampleSegmentNum++;
190+
#if ENABLE_DEBUGGING
191+
Log.Debug("ExampleStreamingSplitSamples.RecordingHandler()", "Iterating sampleSegmentNum: {0}", sampleSegmentNum);
192+
#endif
193+
}
194+
else
195+
{
196+
sampleSegmentNum = 0;
197+
#if ENABLE_DEBUGGING
198+
Log.Debug("ExampleStreamingSplitSamples.RecordingHandler()", "Resetting sampleSegmentNum: {0}", sampleSegmentNum);
199+
#endif
200+
}
201+
202+
#if ENABLE_TIME_LOGGING
203+
Log.Debug("ExampleStreamingSplitSamples.RecordingHandler", "Sending data - time since last transmission: {0} ms", Mathf.Floor((float)(DateTime.Now - now).TotalMilliseconds));
204+
now = DateTime.Now;
205+
#endif
206+
sampleStart = sampleSegmentSize * sampleSegmentNum;
207+
sampleEnd = sampleSegmentSize * (sampleSegmentNum + 1);
208+
}
209+
210+
yield return 0;
211+
}
212+
213+
yield break;
214+
}
206215

207216
private void OnRecognize(SpeechRecognitionEvent result)
208217
{
@@ -213,25 +222,25 @@ private void OnRecognize(SpeechRecognitionEvent result)
213222
foreach (var alt in res.alternatives)
214223
{
215224
string text = string.Format("{0} ({1}, {2:0.00})\n", alt.transcript, res.final ? "Final" : "Interim", alt.confidence);
216-
Log.Debug("ExampleStreamingSplitSamples.OnRecognize()", text);
225+
Log.Debug("ExampleStreamingSplitSamples.OnRecognize()", text);
217226
ResultsField.text = text;
218227
}
219228

220229
if (res.keywords_result != null && res.keywords_result.keyword != null)
221230
{
222231
foreach (var keyword in res.keywords_result.keyword)
223232
{
224-
Log.Debug("ExampleStreamingSplitSamples.OnRecognize", "keyword: {0}, confidence: {1}, start time: {2}, end time: {3}", keyword.normalized_text, keyword.confidence, keyword.start_time, keyword.end_time);
233+
Log.Debug("ExampleStreamingSplitSamples.OnRecognize", "keyword: {0}, confidence: {1}, start time: {2}, end time: {3}", keyword.normalized_text, keyword.confidence, keyword.start_time, keyword.end_time);
225234
}
226235
}
227236

228237
if (res.word_alternatives != null)
229238
{
230239
foreach (var wordAlternative in res.word_alternatives)
231240
{
232-
Log.Debug("ExampleStreamingSplitSamples.OnRecognize()", "Word alternatives found. Start time: {0} | EndTime: {1}", wordAlternative.start_time, wordAlternative.end_time);
241+
Log.Debug("ExampleStreamingSplitSamples.OnRecognize()", "Word alternatives found. Start time: {0} | EndTime: {1}", wordAlternative.start_time, wordAlternative.end_time);
233242
foreach (var alternative in wordAlternative.alternatives)
234-
Log.Debug("ExampleStreamingSplitSamples.OnRecognie()", "\t word: {0} | confidence: {1}", alternative.word, alternative.confidence);
243+
Log.Debug("ExampleStreamingSplitSamples.OnRecognie()", "\t word: {0} | confidence: {1}", alternative.word, alternative.confidence);
235244
}
236245
}
237246
}
@@ -244,7 +253,7 @@ private void OnRecognizeSpeaker(SpeakerRecognitionEvent result)
244253
{
245254
foreach (SpeakerLabelsResult labelResult in result.speaker_labels)
246255
{
247-
Log.Debug("ExampleStreamingSplitSamples.OnRecongizeSpeaker()", string.Format("speaker result: {0} | confidence: {3} | from: {1} | to: {2}", labelResult.speaker, labelResult.from, labelResult.to, labelResult.confidence));
256+
Log.Debug("ExampleStreamingSplitSamples.OnRecongizeSpeaker()", string.Format("speaker result: {0} | confidence: {3} | from: {1} | to: {2}", labelResult.speaker, labelResult.from, labelResult.to, labelResult.confidence));
248257
}
249258
}
250259
}

Scripts/Connection/WSConnector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public static string FixupURL(string URL)
185185
/// <summary>
186186
/// Create a WSConnector for the given service and function.
187187
/// </summary>
188-
/// <param name="serviceID">The ID of the service.</param>
188+
/// <param name="credentials">The credentials for the service.</param>
189189
/// <param name="function">The name of the function to connect.</param>
190190
/// <param name="args">Additional function arguments.</param>
191191
/// <returns>The WSConnector object or null or error.</returns>

Scripts/Services/Conversation/v1/Conversation.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ public Credentials Credentials
8787
#endregion
8888

8989
#region Constructor
90+
/// <summary>
91+
/// Conversation constructor
92+
/// </summary>
93+
/// <param name="credentials">The service credentials</param>
9094
public Conversation(Credentials credentials)
9195
{
9296
if (credentials.HasCredentials() || credentials.HasAuthorizationToken())

Scripts/Services/Discovery/v1/Discovery.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ public Credentials Credentials
9696
#endregion
9797

9898
#region Constructor
99+
/// <summary>
100+
/// Discovery constructor.
101+
/// </summary>
102+
/// <param name="credentials">The service credentials.</param>
99103
public Discovery(Credentials credentials)
100104
{
101105
if (credentials.HasCredentials() || credentials.HasAuthorizationToken())
@@ -1714,7 +1718,7 @@ private void OnGetFieldsResponse(RESTConnector.Request req, RESTConnector.Respon
17141718
/// <param name="environmentID">The environment identifier.</param>
17151719
/// <param name="collectionID">The collection identifier.</param>
17161720
/// <param name="contentData">A byte array of content to be ingested.</param>
1717-
/// <param name="contentMimeType">The mimeType of the content data to be ingested./param>
1721+
/// <param name="contentMimeType">The mimeType of the content data to be ingested.</param>
17181722
/// <param name="configurationFilePath">The file path to the configuration to use to process the document.</param>
17191723
/// <param name="metadata">If you're using the Data Crawler to upload your documents, you can test a document against the type
17201724
/// of metadata that the Data Crawler might send. The maximum supported metadata file size is 1 MB. Metadata parts larger than
@@ -1766,12 +1770,12 @@ private void OnGetFieldsResponse(RESTConnector.Request req, RESTConnector.Respon
17661770
/// <param name="environmentID">The environment identifier.</param>
17671771
/// <param name="collectionID">The collection identifier.</param>
17681772
/// <param name="contentData">A byte array of content to be ingested.</param>
1769-
/// <param name="contentMimeType">The mimeType of the content data to be ingested./param>
1773+
/// <param name="contentMimeType">The mimeType of the content data to be ingested.</param>
17701774
/// <param name="configurationID">The configuration identifier. If this is specified, do not specify a configuration.</param>
17711775
/// <param name="configuration">A json string of the configuration to test. If this is specified, do not specify a configurationID.</param>
1772-
/// <param name="metadata">If you're using the Data Crawler to upload your documents, you can test a document against the type
1773-
/// of metadata that the Data Crawler might send. The maximum supported metadata file size is 1 MB. Metadata parts larger than
1774-
/// 1 MB are rejected. Example: { "Creator": "Johnny Appleseed", "Subject": "Apples" }</param>
1776+
/// <param name="metadata">If you're using the Data Crawler to upload your documents, you can test a document against the type of metadata
1777+
/// that the Data Crawler might send. The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB are rejected.
1778+
/// Example: { "Creator": "Johnny Appleseed", "Subject": "Apples" }</param>
17751779
/// <param name="customData">Optional custom data.</param>
17761780
/// <returns>True if the call succeeds, false if the call is unsuccessful.</returns>
17771781
public bool AddDocument(SuccessCallback<DocumentAccepted> successCallback, FailCallback failCallback, string environmentID, string collectionID, byte[] contentData, string contentMimeType, string configurationID = default(string), string configuration = default(string), string metadata = default(string), Dictionary<string, object> customData = null)
@@ -2136,7 +2140,7 @@ private void OnGetDocumentResponse(RESTConnector.Request req, RESTConnector.Resp
21362140
/// <param name="collectionID">The collection identifier.</param>
21372141
/// <param name="documentID">The document identifier.</param>
21382142
/// <param name="contentData">A byte array of content to be ingested.</param>
2139-
/// <param name="contentMimeType">The mimeType of the content data to be ingested./param>
2143+
/// <param name="contentMimeType">The mimeType of the content data to be ingested.</param>
21402144
/// <param name="configurationID">The identifier of the configuration to use to process the document.</param>
21412145
/// <param name="metadata">If you're using the Data Crawler to upload your documents, you can test a document against the type
21422146
/// of metadata that the Data Crawler might send. The maximum supported metadata file size is 1 MB. Metadata parts larger than
@@ -2174,7 +2178,7 @@ private void OnGetDocumentResponse(RESTConnector.Request req, RESTConnector.Resp
21742178
/// <param name="collectionID">The collection identifier.</param>
21752179
/// <param name="documentID">The document identifier.</param>
21762180
/// <param name="contentData">A byte array of content to be ingested.</param>
2177-
/// <param name="contentMimeType">The mimeType of the content data to be ingested./param>
2181+
/// <param name="contentMimeType">The mimeType of the content data to be ingested.</param>
21782182
/// <param name="configurationFilePath">The file path to the configuration to use to process</param>
21792183
/// <param name="metadata">If you're using the Data Crawler to upload your documents, you can test a document against the type
21802184
/// of metadata that the Data Crawler might send. The maximum supported metadata file size is 1 MB. Metadata parts larger than

Scripts/Services/PersonalityInsights/v3/DataModels.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public class Warning
178178
public string warning_id { get; set; }
179179
/// <summary>
180180
/// The message associated with the `warning_id`. For `WORD_COUNT_MESSAGE`, "There were
181-
/// <number> words in the input. We need a minimum of 600, preferably 1,200 or more, to
181+
/// &gt;number&lt; words in the input. We need a minimum of 600, preferably 1,200 or more, to
182182
/// compute statistically significant estimates."; for `JSON_AS_TEXT`, "Request input
183183
/// was processed as text/plain as indicated, however detected a JSON input. Did you
184184
/// mean application/json?"; and for `PARTIAL_TEXT_USED`, "The text provided to compute the

0 commit comments

Comments
 (0)