Type Annotations for boto3 Voice ID

1.42.3 · active · verified Sat Apr 11

mypy-boto3-voice-id provides static type annotations for the AWS Voice ID service within the `boto3` library. It enhances developer experience with tools like MyPy, Pyright, and IDEs, offering features like autocompletion and static type checking for `boto3.client('voice-id')` calls. This package, currently at version 1.42.3, is automatically generated by the `youtype/mypy_boto3_builder` project, ensuring type definitions are kept up-to-date with the corresponding `boto3` releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `mypy-boto3-voice-id` for type-hinting a `boto3` Voice ID client and its responses. It utilizes a `TYPE_CHECKING` guard to ensure the type stubs are only used during static analysis, preventing a runtime dependency in production environments.

import boto3
from typing import TYPE_CHECKING

# Recommended: Use TYPE_CHECKING to avoid runtime dependency on mypy-boto3-voice-id
if TYPE_CHECKING:
    from mypy_boto3_voice_id.client import VoiceIDClient
    from mypy_boto3_voice_id.type_defs import ListDomainsResponseTypeDef

def list_voice_id_domains():
    # Type-hint the boto3 client for static analysis
    client: VoiceIDClient = boto3.client("voice-id")
    
    # The response will also be type-checked
    response: ListDomainsResponseTypeDef = client.list_domains()
    
    print("Voice ID Domains:")
    for domain in response.get("DomainSummaries", []):
        print(f"  ID: {domain['DomainId']}, Name: {domain['Name']}")

if __name__ == "__main__":
    # Ensure AWS credentials are configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
    # or AWS CLI config for this to run successfully.
    list_voice_id_domains()

view raw JSON →