private void AddWords()
        {
            IamAuthenticator authenticator = new IamAuthenticator(
                apikey: "{apikey}");

            TextToSpeechService service = new TextToSpeechService(authenticator);

            service.SetServiceUrl("{serviceUrl}");

            var words = new List <Word>()
            {
                new Word()
                {
                    _Word       = "EEE",
                    Translation = "<phoneme alphabet=\"ibm\" ph=\"tr1Ipxl.1i\"></phoneme>"
                },
                new Word()
                {
                    _Word       = "IEEE",
                    Translation = "<phoneme alphabet=\"ibm\" ph=\"1Y.tr1Ipxl.1i\"></phoneme>"
                }
            };

            var result = service.AddWords(
                customizationId: "{customizationId}",
                words: words
                );

            Console.WriteLine(result.StatusCode);
        }
Пример #2
0
        public void AddWords_Success()
        {
            IClient  client  = Substitute.For <IClient>();
            IRequest request = Substitute.For <IRequest>();

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

            TextToSpeechService service = new TextToSpeechService(client);

            var customizationId = "customizationId";
            var words           = new List <Word>();

            var result = service.AddWords(customizationId: customizationId, words: words);

            JObject bodyObject = new JObject();

            if (words != null && words.Count > 0)
            {
                bodyObject["words"] = JToken.FromObject(words);
            }
            var json = JsonConvert.SerializeObject(bodyObject);

            request.Received().WithBodyContent(Arg.Is <StringContent>(x => x.ReadAsStringAsync().Result.Equals(json)));
            client.Received().PostAsync($"{service.ServiceUrl}/v1/customizations/{customizationId}/words");
        }
Пример #3
0
        private BaseModel AddWords(string customizationId, Words customWords, Dictionary <string, object> customData = null)
        {
            Console.WriteLine("\nAttempting to AddWords()");
            var result = service.AddWords(customizationId: customizationId, customWords: customWords, customData: customData);

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

            return(result);
        }
        public IEnumerator TestAddWords()
        {
            Log.Debug("TextToSpeechServiceV1IntegrationTests", "Attempting to AddWords...");
            bool        isComplete = false;
            List <Word> words      = new List <Word>()
            {
                new Word()
                {
                    _Word       = "hello",
                    Translation = "hullo"
                },
                new Word()
                {
                    _Word       = "goodbye",
                    Translation = "gbye"
                },
                new Word()
                {
                    _Word       = "hi",
                    Translation = "ohioooo"
                }
            };

            service.AddWords(
                callback: (DetailedResponse <object> response, IBMError error) =>
            {
                Log.Debug("TextToSpeechServiceV1IntegrationTests", "AddWords result: {0}", response.Response);
                Assert.IsTrue(response.StatusCode == 200);
                Assert.IsNull(error);
                isComplete = true;
            },
                customizationId: customizationId,
                words: words
                );

            while (!isComplete)
            {
                yield return(null);
            }
        }
Пример #5
0
        private void AddWords()
        {
            TokenOptions tokenOptions = new TokenOptions()
            {
                IamApiKey  = apikey,
                ServiceUrl = url
            };

            TextToSpeechService service = new TextToSpeechService(tokenOptions);

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

            var result = service.AddWords(
                customizationId: customizationId,
                words: words
                );

            Console.WriteLine(result.StatusCode);
        }
Пример #6
0
        private void AddWords()
        {
            IamConfig config = new IamConfig(
                apikey: apikey
                );

            TextToSpeechService service = new TextToSpeechService(config);

            service.SetEndpoint(url);

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

            var result = service.AddWords(
                customizationId: customizationId,
                words: words
                );

            Console.WriteLine(result.StatusCode);
        }
        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);
        }