Skip to content

describe_voices async

describe_voices(
    *,
    config_overrides: Optional[AsyncPollyClientConfig] = None,
    engine: Optional[Engine] = None,
    language_code: Optional[LanguageCode] = None,
    include_additional_language_codes: Optional[IncludeAdditionalLanguageCodes] = None,
    next_token: Optional[NextToken] = None,
) -> DescribeVoicesOutput

Returns the list of voices that are available for use when requesting speech synthesis. Each voice speaks a specified language, is either male or female, and is identified by an ID, which is the ASCII version of the voice name.

When synthesizing speech ( SynthesizeSpeech ), you provide the voice ID for the voice you want from the list of voices returned by DescribeVoices.

For example, you want your news reader application to read news in a specific language, but giving a user the option to choose the voice. Using the DescribeVoices operation you can provide the user with a list of available voices to select from.

You can optionally specify a language code to filter the available voices. For example, if you specify en-US, the operation returns a list of all available US English voices.

This operation requires permissions to perform the polly:DescribeVoices action.

Parameters:

  • engine (Optional[Engine], default: None ) –

    Specifies the engine (standard, neural, long-form or generative) used by Amazon Polly when processing input text for speech synthesis.

  • language_code (Optional[LanguageCode], default: None ) –

    The language identification tag (ISO 639 code for the language name-ISO 3166 country code) for filtering the list of voices returned. If you don't specify this optional parameter, all available voices are returned.

  • include_additional_language_codes (Optional[IncludeAdditionalLanguageCodes], default: None ) –

    Boolean value indicating whether to return any bilingual voices that use the specified language as an additional language. For instance, if you request all languages that use US English (es-US), and there is an Italian voice that speaks both Italian (it-IT) and US English, that voice will be included if you specify yes but not if you specify no.

  • next_token (Optional[NextToken], default: None ) –

    An opaque pagination token returned from the previous DescribeVoices operation. If present, this indicates where to continue the listing.

Raises:

Examples:

To describe available voices Returns the list of voices that are available for use when requesting speech synthesis. Displayed languages are those within the specified language code. If no language code is specified, voices for all available languages are displayed.

>>> await client.describe_voices(language_code='en-GB')
Source code in docs_src/capo_polly/_services/async_polly.py
async def describe_voices(
    self,
    *,
    config_overrides: Optional[AsyncPollyClientConfig] = None,
    engine: Optional["capo_polly.types.engine.Engine"] = None,
    language_code: Optional["capo_polly.types.language_code.LanguageCode"] = None,
    include_additional_language_codes: Optional[
        "capo_polly.types.include_additional_language_codes.IncludeAdditionalLanguageCodes"
    ] = None,
    next_token: Optional["capo_polly.types.next_token.NextToken"] = None,
) -> "capo_polly.types.describe_voices_output.DescribeVoicesOutput":
    """<p>Returns the list of voices that are available for use when requesting speech synthesis. Each voice speaks a specified language, is either male or female, and is identified by an ID, which is the ASCII version of the voice name. </p> <p>When synthesizing speech ( <code>SynthesizeSpeech</code> ), you provide the voice ID for the voice you want from the list of voices returned by <code>DescribeVoices</code>.</p> <p>For example, you want your news reader application to read news in a specific language, but giving a user the option to choose the voice. Using the <code>DescribeVoices</code> operation you can provide the user with a list of available voices to select from.</p> <p> You can optionally specify a language code to filter the available voices. For example, if you specify <code>en-US</code>, the operation returns a list of all available US English voices. </p> <p>This operation requires permissions to perform the <code>polly:DescribeVoices</code> action.</p>

    Args:
        engine: <p>Specifies the engine (<code>standard</code>, <code>neural</code>, <code>long-form</code> or <code>generative</code>) used by Amazon Polly when processing input text for speech synthesis. </p>
        language_code: <p> The language identification tag (ISO 639 code for the language name-ISO 3166 country code) for filtering the list of voices returned. If you don't specify this optional parameter, all available voices are returned. </p>
        include_additional_language_codes: <p>Boolean value indicating whether to return any bilingual voices that use the specified language as an additional language. For instance, if you request all languages that use US English (es-US), and there is an Italian voice that speaks both Italian (it-IT) and US English, that voice will be included if you specify <code>yes</code> but not if you specify <code>no</code>.</p>
        next_token: <p>An opaque pagination token returned from the previous <code>DescribeVoices</code> operation. If present, this indicates where to continue the listing.</p>

    Raises:
        capo_polly.errors.invalid_next_token_exception.InvalidNextTokenException: <p>The NextToken is invalid. Verify that it's spelled correctly, and then try again.</p>
        capo_polly.errors.service_failure_exception.ServiceFailureException: <p>An unknown condition has caused a service failure.</p>
        capo_polly.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To describe available voices
        Returns the list of voices that are available for use when requesting speech synthesis. Displayed languages are those within the specified language code. If no language code is specified, voices for all available languages are displayed.

        >>> await client.describe_voices(language_code='en-GB')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_polly.types.describe_voices_input.DescribeVoicesInput]",
    ) -> AsyncOperationResponse[
        "capo_polly.types.describe_voices_output.DescribeVoicesOutput"
    ]:
        import capo_polly._operations.parrot_v1.describe_voices

        (
            output,
            http_response,
        ) = await capo_polly._operations.parrot_v1.describe_voices.async_describe_voices(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DescribeVoices")
    )
    input_: capo_polly.types.describe_voices_input.DescribeVoicesInput = {}
    if engine is not None:
        input_["engine"] = engine
    if language_code is not None:
        input_["language_code"] = language_code
    if include_additional_language_codes is not None:
        input_["include_additional_language_codes"] = (
            include_additional_language_codes
        )
    if next_token is not None:
        input_["next_token"] = next_token

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output