Polly / Client / get_lexicon

get_lexicon#

Polly.Client.get_lexicon(**kwargs)#

Returns the content of the specified pronunciation lexicon stored in an Amazon Web Services Region. For more information, see Managing Lexicons.

See also: AWS API Documentation

Request Syntax

response = client.get_lexicon(
    Name='string'
)
Parameters:

Name (string) –

[REQUIRED]

Name of the lexicon.

Return type:

dict

Returns:

Response Syntax

{
    'Lexicon': {
        'Content': 'string',
        'Name': 'string'
    },
    'LexiconAttributes': {
        'Alphabet': 'string',
        'LanguageCode': 'arb'|'cmn-CN'|'cy-GB'|'da-DK'|'de-DE'|'en-AU'|'en-GB'|'en-GB-WLS'|'en-IN'|'en-US'|'es-ES'|'es-MX'|'es-US'|'fr-CA'|'fr-FR'|'is-IS'|'it-IT'|'ja-JP'|'hi-IN'|'ko-KR'|'nb-NO'|'nl-NL'|'pl-PL'|'pt-BR'|'pt-PT'|'ro-RO'|'ru-RU'|'sv-SE'|'tr-TR'|'en-NZ'|'en-ZA'|'ca-ES'|'de-AT'|'yue-CN'|'ar-AE'|'fi-FI'|'en-IE'|'nl-BE'|'fr-BE'|'cs-CZ'|'de-CH',
        'LastModified': datetime(2015, 1, 1),
        'LexiconArn': 'string',
        'LexemesCount': 123,
        'Size': 123
    }
}

Response Structure

  • (dict) –

    • Lexicon (dict) –

      Lexicon object that provides name and the string content of the lexicon.

      • Content (string) –

        Lexicon content in string format. The content of a lexicon must be in PLS format.

      • Name (string) –

        Name of the lexicon.

    • LexiconAttributes (dict) –

      Metadata of the lexicon, including phonetic alphabetic used, language code, lexicon ARN, number of lexemes defined in the lexicon, and size of lexicon in bytes.

      • Alphabet (string) –

        Phonetic alphabet used in the lexicon. Valid values are ipa and x-sampa.

      • LanguageCode (string) –

        Language code that the lexicon applies to. A lexicon with a language code such as “en” would be applied to all English languages (en-GB, en-US, en-AUS, en-WLS, and so on.

      • LastModified (datetime) –

        Date lexicon was last modified (a timestamp value).

      • LexiconArn (string) –

        Amazon Resource Name (ARN) of the lexicon.

      • LexemesCount (integer) –

        Number of lexemes in the lexicon.

      • Size (integer) –

        Total size of the lexicon, in characters.

Exceptions

Examples

Returns the content of the specified pronunciation lexicon stored in an AWS Region.

response = client.get_lexicon(
    Name='',
)

print(response)

Expected Output:

{
    'Lexicon': {
        'Content': '<?xml version="1.0" encoding="UTF-8"?>\r\n<lexicon version="1.0" \r\n      xmlns="http://www.w3.org/2005/01/pronunciation-lexicon"\r\n      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \r\n      xsi:schemaLocation="http://www.w3.org/2005/01/pronunciation-lexicon \r\n        http://www.w3.org/TR/2007/CR-pronunciation-lexicon-20071212/pls.xsd"\r\n      alphabet="ipa" \r\n      xml:lang="en-US">\r\n  <lexeme>\r\n    <grapheme>W3C</grapheme>\r\n    <alias>World Wide Web Consortium</alias>\r\n  </lexeme>\r\n</lexicon>',
        'Name': 'example',
    },
    'LexiconAttributes': {
        'Alphabet': 'ipa',
        'LanguageCode': 'en-US',
        'LastModified': 1478542980.117,
        'LexemesCount': 1,
        'LexiconArn': 'arn:aws:polly:us-east-1:123456789012:lexicon/example',
        'Size': 503,
    },
    'ResponseMetadata': {
        '...': '...',
    },
}