Esempio n. 1
0
        private Translation GetWord(string customizationId, string word, Dictionary <string, object> customData = null)
        {
            Console.WriteLine("\nAttempting to GetWord()");
            var result = service.GetWord(customizationId: customizationId, word: word, customData: customData);

            if (result != null)
            {
                Console.WriteLine("GetWord() succeeded:\n{0}", JsonConvert.SerializeObject(result, Formatting.Indented));
            }
            else
            {
                Console.WriteLine("Failed to GetWord()");
            }

            return(result);
        }
        private void GetWord()
        {
            IamAuthenticator authenticator = new IamAuthenticator(
                apikey: "{apikey}");

            TextToSpeechService service = new TextToSpeechService(authenticator);

            service.SetServiceUrl("{serviceUrl}");

            var result = service.GetWord(
                customizationId: "{customizationId}",
                word: "ACLs"
                );

            Console.WriteLine(result.StatusCode);
        }
Esempio n. 3
0
        public void GetWord_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 word            = "word";

            var result = service.GetWord(customizationId: customizationId, word: word);

            client.Received().GetAsync($"{service.ServiceUrl}/v1/customizations/{customizationId}/words/{word}");
        }
Esempio n. 4
0
        private void GetWord()
        {
            TokenOptions tokenOptions = new TokenOptions()
            {
                IamApiKey  = apikey,
                ServiceUrl = url
            };

            TextToSpeechService service = new TextToSpeechService(tokenOptions);

            var result = service.GetWord(
                customizationId: customizationId,
                word: "hello"
                );

            Console.WriteLine(result.StatusCode);
        }
Esempio n. 5
0
        private void GetWord()
        {
            IamConfig config = new IamConfig(
                apikey: apikey
                );

            TextToSpeechService service = new TextToSpeechService(config);

            service.SetEndpoint(url);

            var result = service.GetWord(
                customizationId: customizationId,
                word: "hello"
                );

            Console.WriteLine(result.StatusCode);
        }
        public IEnumerator TestGetWord()
        {
            Log.Debug("TextToSpeechServiceV1IntegrationTests", "Attempting to GetWord...");
            Translation getWordResponse = null;

            service.GetWord(
                callback: (DetailedResponse <Translation> response, IBMError error) =>
            {
                Log.Debug("TextToSpeechServiceV1IntegrationTests", "GetWord result: {0}", response.Response);
                getWordResponse = response.Result;
                Assert.IsNotNull(getWordResponse);
                Assert.IsTrue(getWordResponse._Translation == customWordTranslation);
                Assert.IsNull(error);
            },
                customizationId: customizationId,
                word: customWord
                );

            while (getWordResponse == null)
            {
                yield return(null);
            }
        }
        public void Words_Success()
        {
            service.WithHeader("X-Watson-Test", "1");
            var createVoiceModelResult = service.CreateVoiceModel(
                name: voiceModelName,
                language: "en-US",
                description: voiceModelDescription
                );
            var customizationId = createVoiceModelResult.Result.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 addWordsResult = service.AddWords(
                customizationId: customizationId,
                words: words
                );

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

            service.WithHeader("X-Watson-Test", "1");
            var getWordResult = service.GetWord(
                customizationId: customizationId,
                word: "hello"
                );

            service.WithHeader("X-Watson-Test", "1");
            var addWordResult = service.AddWord(
                customizationId: customizationId,
                word: "IBM",
                translation: "eye bee m",
                partOfSpeech: "noun"
                );

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

            service.WithHeader("X-Watson-Test", "1");
            var deleteWordResult = service.DeleteWord(
                customizationId: customizationId,
                word: "hi"
                );

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

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

            Assert.IsNotNull(checkDeleteWordResult.Result);
            Assert.IsNotNull(checkDeleteWordResult.Result._Words);
            Assert.IsTrue(checkDeleteWordResult.Result._Words.Count == 3);
            Assert.IsNotNull(checkAddWordResult.Result);
            Assert.IsNotNull(checkAddWordResult.Result._Words);
            Assert.IsTrue(checkAddWordResult.Result._Words.Count == 4);
            Assert.IsNotNull(getWordResult.Result);
            Assert.IsTrue(getWordResult.Result._Translation == "hullo");
            Assert.IsNotNull(listWordsResult.Result);
            Assert.IsNotNull(listWordsResult.Result._Words);
            Assert.IsTrue(listWordsResult.Result._Words.Count == 3);
            Assert.IsNotNull(addWordsResult.Result);
        }