Skip to content

Commit e446744

Browse files
committed
integration tests
1 parent 48a2ee0 commit e446744

File tree

6 files changed

+577
-22
lines changed

6 files changed

+577
-22
lines changed

Examples/ServiceExamples/Scripts/ExampleSpeechToText.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ void Start()
4444
//TestCreateSession("en-US_BroadbandModel");
4545

4646
// test GetCustomizations
47-
TestGetCustomizations();
47+
//TestGetCustomizations();
4848

4949
// test create, get and delete customizations
50-
TestCreateCustomization();
50+
//TestCreateCustomization();
5151
}
5252

5353
private void TestGetModels()
@@ -125,31 +125,31 @@ private void TestAddCustomCorpus(string customizationID, string corpusName, bool
125125
private void TestGetCustomWords()
126126
{
127127
Log.Debug("ExampleSpeechToText", "Attempting to get custom words.");
128-
m_SpeechToText.GetCustomWords(OnGetCustomWords, m_CreatedCustomizationID);
128+
m_SpeechToText.GetCustomWords(HandleGetCustomWords, m_CreatedCustomizationID);
129129
}
130130

131131
private void TestAddCustomWordsPath(string customizationID, string wordsJsonPath)
132132
{
133133
Log.Debug("ExampleSpeechToText", "Attempting to add custom words in customization {0} using Words json path {1}", customizationID, wordsJsonPath);
134-
m_SpeechToText.AddCustomWords(OnAddCustomWords, customizationID, wordsJsonPath);
134+
m_SpeechToText.AddCustomWords(HandleAddCustomWords, customizationID, wordsJsonPath);
135135
}
136136

137137
private void TestAddCustomWordsWordsObject(string customizationID, Words words)
138138
{
139139
Log.Debug("ExampleSpeechToText", "Attempting to add custom words in customization {0} using Words object", customizationID);
140-
m_SpeechToText.AddCustomWords(OnAddCustomWords, customizationID, words);
140+
m_SpeechToText.AddCustomWords(HandleAddCustomWords, customizationID, words);
141141
}
142142

143143
private void TestDeleteCustomWord(string customizationID, string word)
144144
{
145145
Log.Debug("ExampleSpeechToText", "Attempting to delete custom word {1} in customization {0}", customizationID, word);
146-
m_SpeechToText.DeleteCustomWord(OnDeleteCustomWord, customizationID, word);
146+
m_SpeechToText.DeleteCustomWord(HandleDeleteCustomWord, customizationID, word);
147147
}
148148

149149
private void TestGetCustomWord(string customizationID, string word)
150150
{
151151
Log.Debug("ExampleSpeechToText", "Attempting to get custom word {1} in customization {0}", customizationID, word);
152-
m_SpeechToText.GetCustomWord(OnGetCustomWord, customizationID, word);
152+
m_SpeechToText.GetCustomWord(HandleGetCustomWord, customizationID, word);
153153
}
154154

155155

@@ -203,7 +203,7 @@ private void HandleOnRecognize (SpeechRecognitionEvent result)
203203
foreach( var alt in res.alternatives )
204204
{
205205
string text = alt.transcript;
206-
Debug.Log(string.Format( "{0} ({1}, {2:0.00})\n", text, res.final ? "Final" : "Interim", alt.confidence));
206+
Log.Debug("ExampleSpeechToText", string.Format( "{0} ({1}, {2:0.00})\n", text, res.final ? "Final" : "Interim", alt.confidence));
207207
}
208208
}
209209
}
@@ -402,7 +402,7 @@ private void HandleAddCustomCorpus(bool success, string customData)
402402
}
403403
}
404404

405-
private void OnGetCustomWords(WordsList wordList, string customData)
405+
private void HandleGetCustomWords(WordsList wordList, string customData)
406406
{
407407
if (!string.IsNullOrEmpty(customData))
408408
Log.Debug("ExampleSpeechToText", "custom data: {0}", customData);
@@ -425,7 +425,7 @@ private void OnGetCustomWords(WordsList wordList, string customData)
425425
}
426426
}
427427

428-
private void OnAddCustomWords(bool success, string customData)
428+
private void HandleAddCustomWords(bool success, string customData)
429429
{
430430
if (!string.IsNullOrEmpty(customData))
431431
Log.Debug("ExampleSpeechToText", "custom data: {0}", customData);
@@ -441,7 +441,7 @@ private void OnAddCustomWords(bool success, string customData)
441441
}
442442
}
443443

444-
private void OnDeleteCustomWord(bool success, string customData)
444+
private void HandleDeleteCustomWord(bool success, string customData)
445445
{
446446
if (!string.IsNullOrEmpty(customData))
447447
Log.Debug("ExampleSpeechToText", "custom data: {0}", customData);
@@ -457,7 +457,7 @@ private void OnDeleteCustomWord(bool success, string customData)
457457
}
458458
}
459459

460-
private void OnGetCustomWord(WordData word, string customData)
460+
private void HandleGetCustomWord(WordData word, string customData)
461461
{
462462
if (!string.IsNullOrEmpty(customData))
463463
Log.Debug("ExampleSpeechToText", "custom data: {0}", customData);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"words": [
3+
{
4+
"word": "watson",
5+
"sounds_like": [
6+
"wat son"
7+
],
8+
"display_as": "Watson"
9+
},
10+
{
11+
"word": "unity",
12+
"sounds_like": [
13+
"you ni tee"
14+
],
15+
"display_as": "Unity"
16+
},
17+
{
18+
"word": "sdk",
19+
"sounds_like": [
20+
"S.D.K."
21+
],
22+
"display_as": "SDK"
23+
}
24+
]
25+
}

Examples/ServiceExamples/TestData/test-stt-words.json.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.

Scripts/Services/SpeechToText/DataModels.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ public class Word
670670
/// <summary>
671671
/// What the word sounds like.
672672
/// </summary>
673-
public string sounds_like { get; set; }
673+
public string[] sounds_like { get; set; }
674674
/// <summary>
675675
/// How the word is displayed.
676676
/// </summary>

Scripts/Services/SpeechToText/SpeechToText.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ private void OnGetCustomizationsResp(RESTConnector.Request req, RESTConnector.Re
901901
CustomLanguage customLanguage = new CustomLanguage();
902902
customLanguage.name = name;
903903
customLanguage.base_model_name = base_model_name;
904-
customLanguage.description = description;
904+
customLanguage.description = string.IsNullOrEmpty(description) ? name : description;
905905

906906
fsData data;
907907
sm_Serializer.TrySerialize(customLanguage.GetType(), customLanguage, out data).AssertSuccessWithoutWarnings();
@@ -1484,7 +1484,7 @@ private void OnDeleteCustomCorpusResp(RESTConnector.Request req, RESTConnector.R
14841484
req.Data = customData;
14851485
req.Headers["Content-Type"] = "application/x-www-form-urlencoded";
14861486
req.Headers["Accept"] = "application/json";
1487-
req.Parameters["allow_overwrite"] = allowOverwrite;
1487+
req.Parameters["allow_overwrite"] = allowOverwrite.ToString();
14881488
req.Forms = new Dictionary<string, RESTConnector.Form>();
14891489
req.Forms["body"] = new RESTConnector.Form(trainingData, "trainingData.txt", "text/plain");
14901490
req.OnResponse = OnAddCustomCorpusResp;
@@ -1628,7 +1628,9 @@ private void OnGetCustomWordsResp(RESTConnector.Request req, RESTConnector.Respo
16281628
if (string.IsNullOrEmpty(wordsJsonPath))
16291629
throw new ArgumentNullException("A wordsJsonPath is required to add words to a custom language model.");
16301630

1631-
return AddCustomWords(callback, customizationID, File.ReadAllText(wordsJsonPath));
1631+
string wordsJson = File.ReadAllText(wordsJsonPath);
1632+
1633+
return AddCustomWords(callback, customizationID, wordsJson);
16321634
}
16331635

16341636
public bool AddCustomWords(AddCustomWordsCallback callback, string customizationID, Words words, string customData = default(string))

0 commit comments

Comments
 (0)