Skip to content

Commit c874706

Browse files
committed
integration tests
1 parent 7a380a6 commit c874706

5 files changed

Lines changed: 393 additions & 114 deletions

File tree

Examples/ServiceExamples/Scripts/ExampleTextToSpeech.cs

Lines changed: 108 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -29,114 +29,114 @@ void Start ()
2929
{
3030
LogSystem.InstallDefaultReactors();
3131

32-
//// Get Voices
33-
//Log.Debug("ExampleTextToSpeech", "Attempting to get voices.");
34-
//m_TextToSpeech.GetVoices(OnGetVoices);
35-
36-
//// Get Voice
37-
////string selectedVoice = "en-US_AllisonVoice";
38-
//Log.Debug("ExampleTextToSpeech", "Attempting to get voice {0}.", VoiceType.en_US_Allison);
39-
//m_TextToSpeech.GetVoice(OnGetVoice, VoiceType.en_US_Allison);
40-
41-
//// Get Pronunciation
42-
//string testWord = "Watson";
43-
//Log.Debug("ExampleTextToSpeech", "Attempting to get pronunciation of {0}", testWord);
44-
//m_TextToSpeech.GetPronunciation(OnGetPronunciation, testWord, VoiceType.en_US_Allison);
45-
46-
// Get Customizations
47-
//Log.Debug("ExampleTextToSpeech", "Attempting to get a list of customizations");
48-
//m_TextToSpeech.GetCustomizations(OnGetCustomizations);
49-
50-
// Create Customization
51-
//Log.Debug("ExampleTextToSpeech", "Attempting to create a customization");
52-
//string customizationName = "unity-example-customization";
53-
//string customizationLanguage = "en-US";
54-
//string customizationDescription = "A text to speech voice customization created within Unity.";
55-
//m_TextToSpeech.CreateCustomization(OnCreateCustomization, customizationName, customizationLanguage, customizationDescription);
56-
57-
// Delete Customization
58-
//Log.Debug("ExampleTextToSpeech", "Attempting to delete a customization");
59-
//string customizationIdentifierToDelete = "1476ea80-5355-4911-ac99-ba39162a2d34";
60-
//if (!m_TextToSpeech.DeleteCustomization(OnDeleteCustomization, customizationIdentifierToDelete))
61-
// Log.Debug("ExampleTextToSpeech", "Failed to delete custom voice model!");
62-
63-
// Get Customization
64-
//Log.Debug("ExampleTextToSpeech", "Attempting to get a customization");
65-
//string customizationIdentifierToGet = "1476ea80-5355-4911-ac99-ba39162a2d34";
66-
//if (!m_TextToSpeech.GetCustomization(OnGetCustomization, customizationIdentifierToGet))
67-
// Log.Debug("ExampleTextToSpeech", "Failed to get custom voice model!");
68-
69-
// Update Customization
70-
//Log.Debug("ExampleTextToSpeech", "Attempting to update a customization");
71-
//Word word0 = new Word();
72-
//word0.word = "hello";
73-
//word0.translation = "hullo";
74-
//Word word1 = new Word();
75-
//word1.word = "goodbye";
76-
//word1.translation = "gbye";
77-
//Word word2 = new Word();
78-
//word2.word = "hi";
79-
//word2.translation = "ohiooo";
80-
//Word[] words = { word0, word1, word2 };
81-
//CustomVoiceUpdate customVoiceUpdate = new CustomVoiceUpdate();
82-
//customVoiceUpdate.words = words;
83-
//customVoiceUpdate.description = "My updated description";
84-
//customVoiceUpdate.name = "My updated name";
85-
//string customizationIdToUpdate = "1476ea80-5355-4911-ac99-ba39162a2d34";
86-
//if (!m_TextToSpeech.UpdateCustomization(OnUpdateCustomization, customizationIdToUpdate, customVoiceUpdate))
87-
// Log.Debug("ExampleTextToSpeech", "Failed to update customization!");
88-
89-
// Get Customization Words
90-
//Log.Debug("ExampleTextToSpeech", "Attempting to get a customization's words");
91-
//string customIdentifierToGetWords = "1476ea80-5355-4911-ac99-ba39162a2d34";
92-
//if (!m_TextToSpeech.GetCustomizationWords(OnGetCustomizationWords, customIdentifierToGetWords))
93-
// Log.Debug("ExampleTextToSpeech", "Failed to get {0} words!", customIdentifierToGetWords);
94-
95-
// Add Customization Words
96-
//Log.Debug("ExampleTextToSpeech", "Attempting to add words to a customization");
97-
//string customIdentifierToAddWords = "1476ea80-5355-4911-ac99-ba39162a2d34";
98-
//Words words = new Words();
99-
//Word word0 = new Word();
100-
//word0.word = "bananna";
101-
//word0.translation = "bunanna";
102-
//Word word1 = new Word();
103-
//word1.word = "orange";
104-
//word1.translation = "arange";
105-
//Word word2 = new Word();
106-
//word2.word = "tomato";
107-
//word2.translation = "tomahto";
108-
//Word[] wordArray = { word0, word1, word2 };
109-
//words.words = wordArray;
110-
//if (!m_TextToSpeech.AddCustomizationWords(OnAddCustomizationWords, customIdentifierToAddWords, words))
111-
// Log.Debug("ExampleTextToSpeech", "Failed to add words to {0}!", customIdentifierToAddWords);
112-
113-
// Delete Customization Word
114-
//Log.Debug("ExampleTextToSpeech", "Attempting to delete customization word from custom voice model.");
115-
//string customIdentifierToDeleteWord = "1476ea80-5355-4911-ac99-ba39162a2d34";
116-
//string wordToDelete = "goodbye";
117-
//if (!m_TextToSpeech.DeleteCustomizationWord(OnDeleteCustomizationWord, customIdentifierToDeleteWord, wordToDelete))
118-
// Log.Debug("ExampleTextToSpeech", "Failed to delete {0} from {1}!", wordToDelete, customIdentifierToDeleteWord);
119-
120-
// Get Customization Word
121-
//Log.Debug("ExampleTextToSpeech", "Attempting to get the translation of a custom voice model's word.");
122-
//string customIdentifierToGetWord = "1476ea80-5355-4911-ac99-ba39162a2d34";
123-
//string customIdentifierWord = "hello";
124-
//if (!m_TextToSpeech.GetCustomizationWord(OnGetCustomizationWord, customIdentifierToGetWord, customIdentifierWord))
125-
// Log.Debug("ExampleTextToSpeech", "Failed to get the translation of {0} from {1}!", customIdentifierWord, customIdentifierToGetWord);
126-
127-
// Add Customization Word - This is not working. The PUT method is not supported by Unity.
128-
//Log.Debug("ExampleTextToSpeech", "Attempting to add a single word and translation to a custom voice model.");
129-
//string customIdentifierToAddWordAndTranslation = "1476ea80-5355-4911-ac99-ba39162a2d34";
130-
//string word = "grasshopper";
131-
//string translation = "guhrasshoppe";
132-
//if (!m_TextToSpeech.AddCustomizationWord(OnAddCustomizationWord, customIdentifierToAddWordAndTranslation, word, translation))
133-
// Log.Debug("ExampleTextToSpeech", "Failed to add {0}/{1} to {2}!", word, translation, customIdentifierToAddWordAndTranslation);
134-
135-
136-
//m_TextToSpeech.Voice = VoiceType.en_US_Allison;
137-
//m_TextToSpeech.ToSpeech(m_TestString, HandleToSpeechCallback, true);
138-
139-
}
32+
//// Get Voices
33+
//Log.Debug("ExampleTextToSpeech", "Attempting to get voices.");
34+
//m_TextToSpeech.GetVoices(OnGetVoices);
35+
36+
//// Get Voice
37+
////string selectedVoice = "en-US_AllisonVoice";
38+
//Log.Debug("ExampleTextToSpeech", "Attempting to get voice {0}.", VoiceType.en_US_Allison);
39+
//m_TextToSpeech.GetVoice(OnGetVoice, VoiceType.en_US_Allison);
40+
41+
//// Get Pronunciation
42+
//string testWord = "Watson";
43+
//Log.Debug("ExampleTextToSpeech", "Attempting to get pronunciation of {0}", testWord);
44+
//m_TextToSpeech.GetPronunciation(OnGetPronunciation, testWord, VoiceType.en_US_Allison);
45+
46+
// Get Customizations
47+
//Log.Debug("ExampleTextToSpeech", "Attempting to get a list of customizations");
48+
//m_TextToSpeech.GetCustomizations(OnGetCustomizations);
49+
50+
// Create Customization
51+
//Log.Debug("ExampleTextToSpeech", "Attempting to create a customization");
52+
//string customizationName = "unity-example-customization";
53+
//string customizationLanguage = "en-US";
54+
//string customizationDescription = "A text to speech voice customization created within Unity.";
55+
//m_TextToSpeech.CreateCustomization(OnCreateCustomization, customizationName, customizationLanguage, customizationDescription);
56+
57+
// Delete Customization
58+
//Log.Debug("ExampleTextToSpeech", "Attempting to delete a customization");
59+
//string customizationIdentifierToDelete = "1476ea80-5355-4911-ac99-ba39162a2d34";
60+
//if (!m_TextToSpeech.DeleteCustomization(OnDeleteCustomization, customizationIdentifierToDelete))
61+
// Log.Debug("ExampleTextToSpeech", "Failed to delete custom voice model!");
62+
63+
// Get Customization
64+
//Log.Debug("ExampleTextToSpeech", "Attempting to get a customization");
65+
//string customizationIdentifierToGet = "1476ea80-5355-4911-ac99-ba39162a2d34";
66+
//if (!m_TextToSpeech.GetCustomization(OnGetCustomization, customizationIdentifierToGet))
67+
// Log.Debug("ExampleTextToSpeech", "Failed to get custom voice model!");
68+
69+
// Update Customization
70+
Log.Debug("ExampleTextToSpeech", "Attempting to update a customization");
71+
Word word0 = new Word();
72+
word0.word = "hello";
73+
word0.translation = "hullo";
74+
Word word1 = new Word();
75+
word1.word = "goodbye";
76+
word1.translation = "gbye";
77+
Word word2 = new Word();
78+
word2.word = "hi";
79+
word2.translation = "ohiooo";
80+
Word[] words = { word0, word1, word2 };
81+
CustomVoiceUpdate customVoiceUpdate = new CustomVoiceUpdate();
82+
customVoiceUpdate.words = words;
83+
customVoiceUpdate.description = "My updated description";
84+
customVoiceUpdate.name = "My updated name";
85+
string customizationIdToUpdate = "1476ea80-5355-4911-ac99-ba39162a2d34";
86+
if (!m_TextToSpeech.UpdateCustomization(OnUpdateCustomization, customizationIdToUpdate, customVoiceUpdate))
87+
Log.Debug("ExampleTextToSpeech", "Failed to update customization!");
88+
89+
// Get Customization Words
90+
//Log.Debug("ExampleTextToSpeech", "Attempting to get a customization's words");
91+
//string customIdentifierToGetWords = "1476ea80-5355-4911-ac99-ba39162a2d34";
92+
//if (!m_TextToSpeech.GetCustomizationWords(OnGetCustomizationWords, customIdentifierToGetWords))
93+
// Log.Debug("ExampleTextToSpeech", "Failed to get {0} words!", customIdentifierToGetWords);
94+
95+
// Add Customization Words
96+
//Log.Debug("ExampleTextToSpeech", "Attempting to add words to a customization");
97+
//string customIdentifierToAddWords = "1476ea80-5355-4911-ac99-ba39162a2d34";
98+
//Words words = new Words();
99+
//Word word0 = new Word();
100+
//word0.word = "bananna";
101+
//word0.translation = "bunanna";
102+
//Word word1 = new Word();
103+
//word1.word = "orange";
104+
//word1.translation = "arange";
105+
//Word word2 = new Word();
106+
//word2.word = "tomato";
107+
//word2.translation = "tomahto";
108+
//Word[] wordArray = { word0, word1, word2 };
109+
//words.words = wordArray;
110+
//if (!m_TextToSpeech.AddCustomizationWords(OnAddCustomizationWords, customIdentifierToAddWords, words))
111+
// Log.Debug("ExampleTextToSpeech", "Failed to add words to {0}!", customIdentifierToAddWords);
112+
113+
// Delete Customization Word
114+
//Log.Debug("ExampleTextToSpeech", "Attempting to delete customization word from custom voice model.");
115+
//string customIdentifierToDeleteWord = "1476ea80-5355-4911-ac99-ba39162a2d34";
116+
//string wordToDelete = "goodbye";
117+
//if (!m_TextToSpeech.DeleteCustomizationWord(OnDeleteCustomizationWord, customIdentifierToDeleteWord, wordToDelete))
118+
// Log.Debug("ExampleTextToSpeech", "Failed to delete {0} from {1}!", wordToDelete, customIdentifierToDeleteWord);
119+
120+
// Get Customization Word
121+
//Log.Debug("ExampleTextToSpeech", "Attempting to get the translation of a custom voice model's word.");
122+
//string customIdentifierToGetWord = "1476ea80-5355-4911-ac99-ba39162a2d34";
123+
//string customIdentifierWord = "hello";
124+
//if (!m_TextToSpeech.GetCustomizationWord(OnGetCustomizationWord, customIdentifierToGetWord, customIdentifierWord))
125+
// Log.Debug("ExampleTextToSpeech", "Failed to get the translation of {0} from {1}!", customIdentifierWord, customIdentifierToGetWord);
126+
127+
// Add Customization Word - This is not working. The PUT method is not supported by Unity.
128+
//Log.Debug("ExampleTextToSpeech", "Attempting to add a single word and translation to a custom voice model.");
129+
//string customIdentifierToAddWordAndTranslation = "1476ea80-5355-4911-ac99-ba39162a2d34";
130+
//string word = "grasshopper";
131+
//string translation = "guhrasshoppe";
132+
//if (!m_TextToSpeech.AddCustomizationWord(OnAddCustomizationWord, customIdentifierToAddWordAndTranslation, word, translation))
133+
// Log.Debug("ExampleTextToSpeech", "Failed to add {0}/{1} to {2}!", word, translation, customIdentifierToAddWordAndTranslation);
134+
135+
136+
//m_TextToSpeech.Voice = VoiceType.en_US_Allison;
137+
//m_TextToSpeech.ToSpeech(m_TestString, HandleToSpeechCallback, true);
138+
139+
}
140140

141141
void HandleToSpeechCallback (AudioClip clip)
142142
{

Scripts/Connection/RESTConnector.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,18 @@ private IEnumerator ProcessRequestQueue()
442442
int nErrorCode = -1;
443443
int nSeperator = www.error.IndexOf(' ');
444444
if (nSeperator > 0 && int.TryParse(www.error.Substring(0, nSeperator).Trim(), out nErrorCode))
445-
bError = nErrorCode != 200;
445+
{
446+
switch (nErrorCode)
447+
{
448+
case 200:
449+
case 201:
450+
bError = false;
451+
break;
452+
default:
453+
bError = true;
454+
break;
455+
}
456+
}
446457

447458
if (bError)
448459
Log.Error("RESTConnector", "URL: {0}, ErrorCode: {1}, Error: {2}, Response: {3}", url, nErrorCode, www.error,
@@ -456,11 +467,11 @@ private IEnumerator ProcessRequestQueue()
456467
Log.Error("RESTConnector", "Request timed out for URL: {0}", url);
457468
bError = true;
458469
}
459-
if (!bError && (www.bytes == null || www.bytes.Length == 0))
470+
/*if (!bError && (www.bytes == null || www.bytes.Length == 0))
460471
{
461472
Log.Warning("RESTConnector", "No data recevied for URL: {0}", url);
462473
bError = true;
463-
}
474+
}*/
464475

465476

466477
// generate the Response object now..

Scripts/Services/TextToSpeech/DataModels.cs

100644100755
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,15 @@ public class Voices
140140
/// The array of Voice objects.
141141
/// </summary>
142142
public Voice[] voices { get; set; }
143+
144+
/// <summary>
145+
/// Check to see if object has data.
146+
/// </summary>
147+
/// <returns>True if has voices, False if no voices.</returns>
148+
public bool HasData()
149+
{
150+
return voices != null && voices.Length > 0;
151+
}
143152
};
144153
#endregion
145154

@@ -168,6 +177,11 @@ public class Customizations
168177
/// A list of voice model customizations.
169178
/// </summary>
170179
public Customization[] customizations { get; set; }
180+
181+
public bool HasData()
182+
{
183+
return customizations != null && customizations.Length > 0;
184+
}
171185
}
172186

173187
/// <summary>
@@ -204,6 +218,11 @@ public class Customization
204218
/// Description of the custom voice model.
205219
/// </summary>
206220
public string description { get; set; }
221+
222+
public bool HasData()
223+
{
224+
return !string.IsNullOrEmpty(customization_id);
225+
}
207226
}
208227

209228
/// <summary>

Scripts/Services/TextToSpeech/TextToSpeech.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ private void OnGetCustomizationWordResp(RESTConnector.Request req, RESTConnector
10671067
/// <returns></returns>
10681068
public bool AddCustomizationWord(AddCustomizationWordCallback callback, string customizationID, string word, string translation, string customData = default(string))
10691069
{
1070-
Log.Error("TextToSpeech", "AddCustomizationWord is not supported. Unity WWW does not support PUT method! Use AddCustomizationWords() instead!")
1070+
Log.Error("TextToSpeech", "AddCustomizationWord is not supported. Unity WWW does not support PUT method! Use AddCustomizationWords() instead!");
10711071
if (callback == null)
10721072
throw new ArgumentNullException("callback");
10731073
if (string.IsNullOrEmpty(customizationID))

0 commit comments

Comments
 (0)