public static void PutLexicon() { String LEXICON_CONTENT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<lexicon version=\"1.0\" xmlns=\"http://www.w3.org/2005/01/pronunciation-lexicon\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + "xsi:schemaLocation=\"http://www.w3.org/2005/01/pronunciation-lexicon http://www.w3.org/TR/2007/CR-pronunciation-lexicon-20071212/pls.xsd\" " + "alphabet=\"ipa\" xml:lang=\"en-US\">" + "<lexeme><grapheme>test1</grapheme><alias>test2</alias></lexeme>" + "</lexicon>"; String LEXICON_NAME = "SampleLexicon"; var client = new AmazonPollyClient(); var putLexiconRequest = new PutLexiconRequest() { Name = LEXICON_NAME, Content = LEXICON_CONTENT }; try { client.PutLexicon(putLexiconRequest); } catch (Exception e) { Console.WriteLine("Exception caught: " + e.Message); } }
/// <summary> /// Stores a pronunciation lexicon in an AWS Region. If a lexicon with the same name already /// exists in the region, it is overwritten by the new lexicon. Lexicon operations have /// eventual consistency, therefore, it might take some time before the lexicon is available /// to the SynthesizeSpeech operation. /// /// /// <para> /// For more information, see <a href="http://docs.aws.amazon.com/polly/latest/dg/managing-lexicons.html">Managing /// Lexicons</a>. /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the PutLexicon service method.</param> /// /// <returns>The response from the PutLexicon service method, as returned by Polly.</returns> /// <exception cref="Amazon.Polly.Model.InvalidLexiconException"> /// Amazon Polly can't find the specified lexicon. Verify that the lexicon's name is spelled /// correctly, and then try again. /// </exception> /// <exception cref="Amazon.Polly.Model.LexiconSizeExceededException"> /// The maximum size of the specified lexicon would be exceeded by this operation. /// </exception> /// <exception cref="Amazon.Polly.Model.MaxLexemeLengthExceededException"> /// The maximum size of the lexeme would be exceeded by this operation. /// </exception> /// <exception cref="Amazon.Polly.Model.MaxLexiconsNumberExceededException"> /// The maximum number of lexicons would be exceeded by this operation. /// </exception> /// <exception cref="Amazon.Polly.Model.ServiceFailureException"> /// An unknown condition has caused a service failure. /// </exception> /// <exception cref="Amazon.Polly.Model.UnsupportedPlsAlphabetException"> /// The alphabet specified by the lexicon is not a supported alphabet. Valid values are /// <code>x-sampa</code> and <code>ipa</code>. /// </exception> /// <exception cref="Amazon.Polly.Model.UnsupportedPlsLanguageException"> /// The language specified in the lexicon is unsupported. For a list of supported languages, /// see <a href="http://docs.aws.amazon.com/polly/latest/dg/API_LexiconAttributes.html">Lexicon /// Attributes</a>. /// </exception> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/PutLexicon">REST API Reference for PutLexicon Operation</seealso> public PutLexiconResponse PutLexicon(PutLexiconRequest request) { var marshaller = new PutLexiconRequestMarshaller(); var unmarshaller = PutLexiconResponseUnmarshaller.Instance; return(Invoke <PutLexiconRequest, PutLexiconResponse>(request, marshaller, unmarshaller)); }
internal virtual PutLexiconResponse PutLexicon(PutLexiconRequest request) { var marshaller = PutLexiconRequestMarshaller.Instance; var unmarshaller = PutLexiconResponseUnmarshaller.Instance; return(Invoke <PutLexiconRequest, PutLexiconResponse>(request, marshaller, unmarshaller)); }
public static async Task Main() { string lexiconContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<lexicon version=\"1.0\" xmlns=\"http://www.w3.org/2005/01/pronunciation-lexicon\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + "xsi:schemaLocation=\"http://www.w3.org/2005/01/pronunciation-lexicon http://www.w3.org/TR/2007/CR-pronunciation-lexicon-20071212/pls.xsd\" " + "alphabet=\"ipa\" xml:lang=\"en-US\">" + "<lexeme><grapheme>test1</grapheme><alias>test2</alias></lexeme>" + "</lexicon>"; string lexiconName = "SampleLexicon"; var client = new AmazonPollyClient(); var putLexiconRequest = new PutLexiconRequest() { Name = lexiconName, Content = lexiconContent, }; try { var response = await client.PutLexiconAsync(putLexiconRequest); if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) { Console.WriteLine($"Successfully created Lexicon: {lexiconName}."); } else { Console.WriteLine($"Could not create Lexicon: {lexiconName}."); } } catch (Exception ex) { Console.WriteLine("Exception caught: " + ex.Message); } }
/// <summary> /// Initiates the asynchronous execution of the PutLexicon operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the PutLexicon 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 EndPutLexicon /// operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/PutLexicon">REST API Reference for PutLexicon Operation</seealso> public IAsyncResult BeginPutLexicon(PutLexiconRequest request, AsyncCallback callback, object state) { var marshaller = new PutLexiconRequestMarshaller(); var unmarshaller = PutLexiconResponseUnmarshaller.Instance; return(BeginInvoke <PutLexiconRequest>(request, marshaller, unmarshaller, callback, state)); }
/// <summary> /// Initiates the asynchronous execution of the PutLexicon operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the PutLexicon 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/PutLexicon">REST API Reference for PutLexicon Operation</seealso> public virtual Task <PutLexiconResponse> PutLexiconAsync(PutLexiconRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = PutLexiconRequestMarshaller.Instance; var unmarshaller = PutLexiconResponseUnmarshaller.Instance; return(InvokeAsync <PutLexiconRequest, PutLexiconResponse>(request, marshaller, unmarshaller, cancellationToken)); }
/// <summary> /// Stores a pronunciation lexicon in an AWS Region. If a lexicon with the same name already /// exists in the region, it is overwritten by the new lexicon. Lexicon operations have /// eventual consistency, therefore, it might take some time before the lexicon is available /// to the SynthesizeSpeech operation. /// /// /// <para> /// For more information, see <a href="https://docs.aws.amazon.com/polly/latest/dg/managing-lexicons.html">Managing /// Lexicons</a>. /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the PutLexicon 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 PutLexicon service method, as returned by Polly.</returns> /// <exception cref="Amazon.Polly.Model.InvalidLexiconException"> /// Amazon Polly can't find the specified lexicon. Verify that the lexicon's name is spelled /// correctly, and then try again. /// </exception> /// <exception cref="Amazon.Polly.Model.LexiconSizeExceededException"> /// The maximum size of the specified lexicon would be exceeded by this operation. /// </exception> /// <exception cref="Amazon.Polly.Model.MaxLexemeLengthExceededException"> /// The maximum size of the lexeme would be exceeded by this operation. /// </exception> /// <exception cref="Amazon.Polly.Model.MaxLexiconsNumberExceededException"> /// The maximum number of lexicons would be exceeded by this operation. /// </exception> /// <exception cref="Amazon.Polly.Model.ServiceFailureException"> /// An unknown condition has caused a service failure. /// </exception> /// <exception cref="Amazon.Polly.Model.UnsupportedPlsAlphabetException"> /// The alphabet specified by the lexicon is not a supported alphabet. Valid values are /// <code>x-sampa</code> and <code>ipa</code>. /// </exception> /// <exception cref="Amazon.Polly.Model.UnsupportedPlsLanguageException"> /// The language specified in the lexicon is unsupported. For a list of supported languages, /// see <a href="https://docs.aws.amazon.com/polly/latest/dg/API_LexiconAttributes.html">Lexicon /// Attributes</a>. /// </exception> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/polly-2016-06-10/PutLexicon">REST API Reference for PutLexicon Operation</seealso> public virtual Task <PutLexiconResponse> PutLexiconAsync(PutLexiconRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = PutLexiconRequestMarshaller.Instance; options.ResponseUnmarshaller = PutLexiconResponseUnmarshaller.Instance; return(InvokeAsync <PutLexiconResponse>(request, options, cancellationToken)); }
internal virtual PutLexiconResponse PutLexicon(PutLexiconRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = PutLexiconRequestMarshaller.Instance; options.ResponseUnmarshaller = PutLexiconResponseUnmarshaller.Instance; return(Invoke <PutLexiconResponse>(request, options)); }