public IEnumerator TestCreateCustomModel()
        {
            Log.Debug("TextToSpeechServiceV1IntegrationTests", "Attempting to CreateCustomModel...");
            CustomModel createCustomModelResponse = null;

            service.CreateCustomModel(
                callback: (DetailedResponse <CustomModel> response, IBMError error) =>
            {
                Log.Debug("TextToSpeechServiceV1IntegrationTests", "CreateCustomModel result: {0}", response.Response);
                createCustomModelResponse = response.Result;
                customizationId           = createCustomModelResponse.CustomizationId;
                Assert.IsNotNull(createCustomModelResponse);
                Assert.IsNotNull(customizationId);
                Assert.IsNull(error);
            },
                name: customModelName,
                language: customModelLanguage,
                description: customModelDescription
                );

            while (createCustomModelResponse == null)
            {
                yield return(null);
            }
        }
Beispiel #2
0
        public void CreateVoiceModel_Success()
        {
            IClient  client  = Substitute.For <IClient>();
            IRequest request = Substitute.For <IRequest>();

            client.PostAsync(Arg.Any <string>())
            .Returns(request);

            TextToSpeechService service = new TextToSpeechService(client);

            var name        = "name";
            var language    = "language";
            var description = "description";

            var result = service.CreateCustomModel(name: name, language: language, description: description);

            JObject bodyObject = new JObject();

            if (!string.IsNullOrEmpty(name))
            {
                bodyObject["name"] = JToken.FromObject(name);
            }
            if (!string.IsNullOrEmpty(language))
            {
                bodyObject["language"] = JToken.FromObject(language);
            }
            if (!string.IsNullOrEmpty(description))
            {
                bodyObject["description"] = JToken.FromObject(description);
            }
            var json = JsonConvert.SerializeObject(bodyObject);

            request.Received().WithBodyContent(Arg.Is <StringContent>(x => x.ReadAsStringAsync().Result.Equals(json)));
        }
        public void CreateVoiceModel()
        {
            IamAuthenticator authenticator = new IamAuthenticator(
                apikey: "{apikey}");

            TextToSpeechService service = new TextToSpeechService(authenticator);

            service.SetServiceUrl("{serviceUrl}");

            var result = service.CreateCustomModel(
                name: "First Model",
                language: "en-US",
                description: "First custom voice model"
                );

            Console.WriteLine(result.Result);

            customizationId = result.Result.CustomizationId;
        }
Beispiel #4
0
        public void CustomVoiceModels_Success()
        {
            service.WithHeader("X-Watson-Test", "1");
            var listVoiceModelsResult = service.ListCustomModels();

            service.WithHeader("X-Watson-Test", "1");
            var createVoiceModelResult = service.CreateCustomModel(
                name: voiceModelName,
                language: "en-US",
                description: voiceModelDescription);
            var customizationId = createVoiceModelResult.Result.CustomizationId;

            service.WithHeader("X-Watson-Test", "1");
            var getVoiceModelResult = service.GetCustomModel(
                customizationId: customizationId
                );

            var words = new List <Word>()
            {
                new Word()
                {
                    _Word       = "hello",
                    Translation = "hullo"
                },
                new Word()
                {
                    _Word       = "goodbye",
                    Translation = "gbye"
                },
                new Word()
                {
                    _Word       = "hi",
                    Translation = "ohioooo"
                }
            };

            service.WithHeader("X-Watson-Test", "1");
            var updateVoiceModelResult = service.UpdateCustomModel(
                customizationId: customizationId,
                name: voiceModelUpdatedName,
                description: voiceModelUpdatedDescription,
                words: words
                );

            service.WithHeader("X-Watson-Test", "1");
            var getVoiceModelResult2 = service.GetCustomModel(
                customizationId: customizationId
                );

            service.WithHeader("X-Watson-Test", "1");
            var deleteVoiceModelResult = service.DeleteCustomModel(
                customizationId: customizationId
                );

            Assert.IsNotNull(deleteVoiceModelResult.StatusCode == 204);
            Assert.IsNotNull(getVoiceModelResult2.Result);
            Assert.IsTrue(getVoiceModelResult2.Result.Name == voiceModelUpdatedName);
            Assert.IsTrue(getVoiceModelResult2.Result.Description == voiceModelUpdatedDescription);
            Assert.IsTrue(getVoiceModelResult2.Result.Words.Count == 3);
            Assert.IsNotNull(getVoiceModelResult.Result);
            Assert.IsTrue(getVoiceModelResult.Result.Name == voiceModelName);
            Assert.IsTrue(getVoiceModelResult.Result.Description == voiceModelDescription);
            Assert.IsNotNull(createVoiceModelResult.Result);
            Assert.IsNotNull(listVoiceModelsResult.Result);
            Assert.IsNotNull(listVoiceModelsResult.Result.Customizations);
        }