Exemplo n.º 1
0
        public static void ListLexicons()
        {
            var client = new AmazonPollyClient();

            var listLexiconsRequest = new ListLexiconsRequest();

            try
            {
                String nextToken;
                do
                {
                    var listLexiconsResponse = client.ListLexicons(listLexiconsRequest);
                    nextToken = listLexiconsResponse.NextToken;
                    listLexiconsResponse.NextToken = nextToken;

                    Console.WriteLine("All voices: ");
                    foreach (var lexiconDescription in listLexiconsResponse.Lexicons)
                    {
                        var attributes = lexiconDescription.Attributes;
                        Console.WriteLine("Name: " + lexiconDescription.Name
                                          + ", Alphabet: " + attributes.Alphabet
                                          + ", LanguageCode: " + attributes.LanguageCode
                                          + ", LastModified: " + attributes.LastModified
                                          + ", LexemesCount: " + attributes.LexemesCount
                                          + ", LexiconArn: " + attributes.LexiconArn
                                          + ", Size: " + attributes.Size);
                    }
                } while (nextToken != null);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception caught: " + e.Message);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a list of pronunciation lexicons stored in an AWS Region. For more information,
        /// see <a href="http://docs.aws.amazon.com/polly/latest/dg/managing-lexicons.html">Managing
        /// Lexicons</a>.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the ListLexicons service method.</param>
        ///
        /// <returns>The response from the ListLexicons service method, as returned by Polly.</returns>
        /// <exception cref="Amazon.Polly.Model.InvalidNextTokenException">
        /// The NextToken is invalid. Verify that it's spelled correctly, and then try again.
        /// </exception>
        /// <exception cref="Amazon.Polly.Model.ServiceFailureException">
        /// An unknown condition has caused a service failure.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/ListLexicons">REST API Reference for ListLexicons Operation</seealso>
        public ListLexiconsResponse ListLexicons(ListLexiconsRequest request)
        {
            var marshaller   = new ListLexiconsRequestMarshaller();
            var unmarshaller = ListLexiconsResponseUnmarshaller.Instance;

            return(Invoke <ListLexiconsRequest, ListLexiconsResponse>(request, marshaller, unmarshaller));
        }
Exemplo n.º 3
0
        internal virtual ListLexiconsResponse ListLexicons(ListLexiconsRequest request)
        {
            var marshaller   = ListLexiconsRequestMarshaller.Instance;
            var unmarshaller = ListLexiconsResponseUnmarshaller.Instance;

            return(Invoke <ListLexiconsRequest, ListLexiconsResponse>(request, marshaller, unmarshaller));
        }
Exemplo n.º 4
0
        public static async Task Main()
        {
            var client  = new AmazonPollyClient();
            var request = new ListLexiconsRequest();

            try
            {
                Console.WriteLine("All voices: ");

                do
                {
                    var response = await client.ListLexiconsAsync(request);

                    request.NextToken = response.NextToken;

                    response.Lexicons.ForEach(lexicon =>
                    {
                        var attributes = lexicon.Attributes;
                        Console.WriteLine($"Name: {lexicon.Name}");
                        Console.WriteLine($"\tAlphabet: {attributes.Alphabet}");
                        Console.WriteLine($"\tLanguageCode: {attributes.LanguageCode}");
                        Console.WriteLine($"\tLastModified: {attributes.LastModified}");
                        Console.WriteLine($"\tLexemesCount: {attributes.LexemesCount}");
                        Console.WriteLine($"\tLexiconArn: {attributes.LexiconArn}");
                        Console.WriteLine($"\tSize: {attributes.Size}");
                    });
                }while (request.NextToken is not null);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex.Message}");
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initiates the asynchronous execution of the ListLexicons operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the ListLexicons operation on AmazonPollyClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        ///
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndListLexicons
        ///         operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/ListLexicons">REST API Reference for ListLexicons Operation</seealso>
        public IAsyncResult BeginListLexicons(ListLexiconsRequest request, AsyncCallback callback, object state)
        {
            var marshaller   = new ListLexiconsRequestMarshaller();
            var unmarshaller = ListLexiconsResponseUnmarshaller.Instance;

            return(BeginInvoke <ListLexiconsRequest>(request, marshaller, unmarshaller,
                                                     callback, state));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initiates the asynchronous execution of the ListLexicons operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the ListLexicons operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/ListLexicons">REST API Reference for ListLexicons Operation</seealso>
        public virtual Task <ListLexiconsResponse> ListLexiconsAsync(ListLexiconsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = ListLexiconsRequestMarshaller.Instance;
            var unmarshaller = ListLexiconsResponseUnmarshaller.Instance;

            return(InvokeAsync <ListLexiconsRequest, ListLexiconsResponse>(request, marshaller,
                                                                           unmarshaller, cancellationToken));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Returns a list of pronunciation lexicons stored in an AWS Region. For more information,
        /// see <a href="https://docs.aws.amazon.com/polly/latest/dg/managing-lexicons.html">Managing
        /// Lexicons</a>.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the ListLexicons service method.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        ///
        /// <returns>The response from the ListLexicons service method, as returned by Polly.</returns>
        /// <exception cref="Amazon.Polly.Model.InvalidNextTokenException">
        /// The NextToken is invalid. Verify that it's spelled correctly, and then try again.
        /// </exception>
        /// <exception cref="Amazon.Polly.Model.ServiceFailureException">
        /// An unknown condition has caused a service failure.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/ListLexicons">REST API Reference for ListLexicons Operation</seealso>
        public virtual Task <ListLexiconsResponse> ListLexiconsAsync(ListLexiconsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = ListLexiconsRequestMarshaller.Instance;
            options.ResponseUnmarshaller = ListLexiconsResponseUnmarshaller.Instance;

            return(InvokeAsync <ListLexiconsResponse>(request, options, cancellationToken));
        }
Exemplo n.º 8
0
        internal virtual ListLexiconsResponse ListLexicons(ListLexiconsRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = ListLexiconsRequestMarshaller.Instance;
            options.ResponseUnmarshaller = ListLexiconsResponseUnmarshaller.Instance;

            return(Invoke <ListLexiconsResponse>(request, options));
        }
Exemplo n.º 9
0
        public IList <LexiconDescription> GetLexicons()
        {
            var lexiconsReq = new ListLexiconsRequest();

            var lexicons = new List <LexiconDescription>();

            do
            {
                var lexiconsRes = this.client.ListLexiconsAsync(lexiconsReq).GetAwaiter().GetResult();
                lexicons.AddRange(lexiconsRes.Lexicons);
                lexiconsReq.NextToken = lexiconsRes.NextToken;
            } while (!string.IsNullOrEmpty(lexiconsReq.NextToken));

            return(lexicons);
        }
Exemplo n.º 10
0
        void ShowLexiconsList()
        {
            if (!RefreshConnection())
            {
                return;
            }

            List <LexiconDescription> lexicons = new List <LexiconDescription>();

            try {
                lexiconsList.Clear();

                ListLexiconsRequest  req = new ListLexiconsRequest();
                ListLexiconsResponse llr = _pc.ListLexicons(req);
                lexicons = llr.Lexicons;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
                return;
            }

            foreach (LexiconDescription ld in lexicons)
            {
                string lexName = ld.Name;
                lexiconsList.Add(lexName);
            }

            string joinedList = "Lexicons: \n\n" + string.Join("\n", lexiconsList);

            joinedList += "\n\n\n Would you like to go to Amazon Console to manage lexicons?";
            if (MessageBox.Show(joinedList, "Available Lexicons", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
            {
                System.Diagnostics.Process.Start("http://" + _region + ".console.aws.amazon.com/polly/home/Lexicons");
            }
        }