Skip to content

delete_voice

delete_voice(
    voice_id: CustomVoiceId, *, config_overrides: Optional[PollyClientConfig] = None
) -> DeleteVoiceOutput

Deletes a custom voice. DescribeVoices and GetVoice stop returning the voice immediately. You can't restore a deleted voice.

You can delete a voice in active or failed status. If the voice is in pending status, the request fails with ConflictException. If no custom voice with the specified ID exists in your account and Region, the request fails with ResourceNotFoundException. You can delete the voice even if you disabled its Amazon Web Services KMS key or scheduled it for deletion.

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

Parameters:

  • voice_id (CustomVoiceId) –

    The ID of the custom voice to delete, for example, vc-9a8fa85dd3. You can't specify the ARN of the voice.

Raises:

  • ConflictException –

    The request conflicts with the current state of the resource. For a custom voice, the voice isn't in the status that the operation requires. Check the status with GetVoice, and then try again.

  • ResourceNotFoundException –

    Amazon Polly can't find the specified resource. Verify that the resource exists in the Amazon Web Services account and Region of the request and that its ARN or ID is spelled correctly, and then try again.

  • ServiceFailureException –

    An unknown condition has caused a service failure.

  • ThrottlingException –

    The request was denied because of request throttling.

  • ValidationException –

    The input fails to satisfy the constraints specified by the service.

  • UnknownServiceError –

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

Source code in docs_src/capo_polly/_services/polly.py
def delete_voice(
    self,
    voice_id: "capo_polly.types.custom_voice_id.CustomVoiceId",
    *,
    config_overrides: Optional[PollyClientConfig] = None,
) -> "capo_polly.types.delete_voice_output.DeleteVoiceOutput":
    """<p>Deletes a custom voice. <code>DescribeVoices</code> and <code>GetVoice</code> stop returning the voice immediately. You can't restore a deleted voice.</p> <p>You can delete a voice in <code>active</code> or <code>failed</code> status. If the voice is in <code>pending</code> status, the request fails with <code>ConflictException</code>. If no custom voice with the specified ID exists in your account and Region, the request fails with <code>ResourceNotFoundException</code>. You can delete the voice even if you disabled its Amazon Web Services KMS key or scheduled it for deletion.</p> <p>This operation requires permissions to perform the <code>polly:DeleteVoice</code> action.</p>

    Args:
        voice_id: <p>The ID of the custom voice to delete, for example, <code>vc-9a8fa85dd3</code>. You can't specify the ARN of the voice.</p>

    Raises:
        capo_polly.errors.conflict_exception.ConflictException: <p>The request conflicts with the current state of the resource. For a custom voice, the voice isn't in the status that the operation requires. Check the status with <code>GetVoice</code>, and then try again.</p>
        capo_polly.errors.resource_not_found_exception.ResourceNotFoundException: <p>Amazon Polly can't find the specified resource. Verify that the resource exists in the Amazon Web Services account and Region of the request and that its ARN or ID is 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.throttling_exception.ThrottlingException: <p>The request was denied because of request throttling.</p>
        capo_polly.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by the service.</p>
        capo_polly.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_polly.types.delete_voice_input.DeleteVoiceInput]",
    ) -> OperationResponse[
        "capo_polly.types.delete_voice_output.DeleteVoiceOutput"
    ]:
        import capo_polly._operations.parrot_v1.delete_voice

        output, http_response = (
            capo_polly._operations.parrot_v1.delete_voice.delete_voice(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteVoice")
    )
    input_: capo_polly.types.delete_voice_input.DeleteVoiceInput = {
        "voice_id": voice_id
    }

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