Skip to content

create_dictionary

create_dictionary(
    name: ResourceName,
    language: DictionaryLanguage,
    *,
    config_overrides: Optional[ElementalInferenceClientConfig] = None,
    entries: Optional[DictionaryEntriesPayload] = None,
    tags: Optional[TagMap] = None,
) -> CreateDictionaryResponse

Creates a custom dictionary for improving transcription accuracy. A dictionary contains custom words and phrases that the ASR engine might not recognize, such as brand names, technical terms, or proper nouns. You can reference a dictionary when configuring a smart subtitles output.

Parameters:

  • name (ResourceName) –

    A user-friendly name for this dictionary.

  • language (DictionaryLanguage) –

    The language of the dictionary entries. Specify the language using an ISO 639-2/T three-letter code. Supported values: eng, fra, ita, deu, spa, por.

  • entries (Optional[DictionaryEntriesPayload], default: None ) –

    The dictionary entries payload. Contains the custom words and phrases for the dictionary. Maximum size is 40,960 characters.

  • tags (Optional[TagMap], default: None ) –

    Optional tags to associate with the dictionary.

Raises:

  • AccessDeniedException –

    You do not have sufficient access to perform this action.

  • ConflictException –

    The request could not be completed due to a conflict.

  • InternalServerErrorException –

    An internal server error occurred. This is a temporary condition and the request can be retried. If the problem persists, contact AWS Support.

  • ServiceQuotaExceededException –

    The request was rejected because it would exceed one or more service quotas for your account. Review your service quotas and either delete unused resources or request a quota increase.

  • TooManyRequestException –

    The request was denied due to request throttling. Too many requests have been made within a given time period. Reduce the frequency of requests and use exponential backoff when retrying.

  • ValidationException –

    The input fails to satisfy the constraints specified by the service. Check the error message for details about which parameter or field is invalid and correct the request before retrying.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_elementalinference/_services/elemental_inference.py
def create_dictionary(
    self,
    name: "capo_elementalinference.types.resource_name.ResourceName",
    language: "capo_elementalinference.types.dictionary_language.DictionaryLanguage",
    *,
    config_overrides: Optional[ElementalInferenceClientConfig] = None,
    entries: Optional[
        "capo_elementalinference.types.dictionary_entries_payload.DictionaryEntriesPayload"
    ] = None,
    tags: Optional["capo_elementalinference.types.tag_map.TagMap"] = None,
) -> "capo_elementalinference.types.create_dictionary_response.CreateDictionaryResponse":
    """<p>Creates a custom dictionary for improving transcription accuracy. A dictionary contains custom words and phrases that the ASR engine might not recognize, such as brand names, technical terms, or proper nouns. You can reference a dictionary when configuring a smart subtitles output. </p>

    Args:
        name: <p>A user-friendly name for this dictionary.</p>
        language: <p>The language of the dictionary entries. Specify the language using an ISO 639-2/T three-letter code. Supported values: eng, fra, ita, deu, spa, por. </p>
        entries: <p>The dictionary entries payload. Contains the custom words and phrases for the dictionary. Maximum size is 40,960 characters. </p>
        tags: <p>Optional tags to associate with the dictionary.</p>

    Raises:
        capo_elementalinference.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_elementalinference.errors.conflict_exception.ConflictException: <p>The request could not be completed due to a conflict.</p>
        capo_elementalinference.errors.internal_server_error_exception.InternalServerErrorException: <p>An internal server error occurred. This is a temporary condition and the request can be retried. If the problem persists, contact AWS Support. </p>
        capo_elementalinference.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request was rejected because it would exceed one or more service quotas for your account. Review your service quotas and either delete unused resources or request a quota increase. </p>
        capo_elementalinference.errors.too_many_request_exception.TooManyRequestException: <p>The request was denied due to request throttling. Too many requests have been made within a given time period. Reduce the frequency of requests and use exponential backoff when retrying. </p>
        capo_elementalinference.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by the service. Check the error message for details about which parameter or field is invalid and correct the request before retrying. </p>
        capo_elementalinference.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_elementalinference.types.create_dictionary_request.CreateDictionaryRequest]",
    ) -> OperationResponse[
        "capo_elementalinference.types.create_dictionary_response.CreateDictionaryResponse"
    ]:
        import capo_elementalinference._operations.elemental_inference.create_dictionary

        output, http_response = (
            capo_elementalinference._operations.elemental_inference.create_dictionary.create_dictionary(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateDictionary")
    )
    input_: capo_elementalinference.types.create_dictionary_request.CreateDictionaryRequest = {
        "name": name,
        "language": language,
    }
    if entries is not None:
        input_["entries"] = entries
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output