public IEnumerator TestGetCustomModel()
        {
            Log.Debug("TextToSpeechServiceV1IntegrationTests", "Attempting to GetCustomModel...");
            CustomModel getCustomModelResponse = null;

            service.GetCustomModel(
                callback: (DetailedResponse <CustomModel> response, IBMError error) =>
            {
                Log.Debug("TextToSpeechServiceV1IntegrationTests", "GetCustomModel result: {0}", response.Response);
                getCustomModelResponse = response.Result;
                Assert.IsNotNull(getCustomModelResponse);
                Assert.IsTrue(getCustomModelResponse.CustomizationId == customizationId);
                Assert.IsTrue(getCustomModelResponse.Name == customModelName);
                Assert.IsTrue(getCustomModelResponse.Language == customModelLanguage);
                Assert.IsTrue(getCustomModelResponse.Description == customModelDescription);
                Assert.IsNull(error);
            },
                customizationId: customizationId
                );

            while (getCustomModelResponse == null)
            {
                yield return(null);
            }
        }
コード例 #2
0
        public void GetVoiceModel()
        {
            IamAuthenticator authenticator = new IamAuthenticator(
                apikey: "{apikey}");

            TextToSpeechService service = new TextToSpeechService(authenticator);

            service.SetServiceUrl("{serviceUrl}");

            var result = service.GetCustomModel(
                customizationId: "{customizationId}"
                );

            Console.WriteLine(result.Result);
        }
コード例 #3
0
        public void GetVoiceModel_Success()
        {
            IClient  client  = Substitute.For <IClient>();
            IRequest request = Substitute.For <IRequest>();

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

            TextToSpeechService service = new TextToSpeechService(client);

            var customizationId = "customizationId";

            var result = service.GetCustomModel(customizationId: customizationId);

            client.Received().GetAsync($"{service.ServiceUrl}/v1/customizations/{customizationId}");
        }
コード例 #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);
        }