Skip to content

transcribe_audio async

transcribe_audio(
    media: SyncMedia,
    *,
    config_overrides: Optional[AsyncTranscribeClientConfig] = None,
    language: Optional[SyncLanguage] = None,
    language_detection_mode: Optional[LanguageDetectionMode] = None,
    language_options: Optional[SyncLanguageOptions] = None,
    channel_identification: Optional[Boolean] = None,
    show_speaker_labels: Optional[Boolean] = None,
    max_speaker_labels: Optional[MaxSpeakers] = None,
    vocabulary_settings: Optional[VocabularySettingsList] = None,
    vocabulary_filter_settings: Optional[VocabularyFilterSettings] = None,
    content_redaction: Optional[ContentRedaction] = None,
    output_configuration: Optional[SyncOutputConfiguration] = None,
) -> TranscribeAudioResponse

Transcribes a media file and returns the transcript in the same response. There is no job to start and no status to poll.

Use TranscribeAudio when you already have a complete media file and want the transcript right away. For large files, long audio, or bulk processing, use .

You must include the following parameters in your TranscribeAudio request:

  • Media: Your audio, either as inline bytes (MediaBytes) or as the Amazon S3 location of a media file (MediaFileUri).

  • One of Language or LanguageDetectionMode: Specify the language of your audio, or have Amazon Transcribe identify it.

Your audio must be between 0.5 seconds and 1 hour long. Supported formats are WAV, MP3, FLAC, M4A, MP4, Ogg, WebM, and AMR.

If you send your audio in the request (MediaBytes), the file can be up to 25 MB. If you provide an Amazon S3 location (MediaFileUri), the file can be up to 500 MB.

Amazon Transcribe always turns on smart formatting, also known as inverse text normalization (ITN). It writes numbers, dates, currency, and similar items in their usual written form. For example, "one hundred" becomes "100". You can't turn smart formatting off.

By default, Amazon Transcribe returns the transcript in TranscriptResponse. If you include OutputConfiguration, Amazon Transcribe writes the transcript to the Amazon S3 location you specify instead, and the response contains only that location.

Parameters:

  • media (SyncMedia) –

    The audio to transcribe. Specify exactly one of MediaBytes or MediaFileUri.

    Audio sent in the request (MediaBytes) can be up to 25 MB. Audio in Amazon S3 (MediaFileUri) can be up to 500 MB.

  • language (Optional[SyncLanguage], default: None ) –

    The language spoken in your audio, as a base language code (for example, en or es).

    Include either Language or LanguageDetectionMode in your request, but not both.

  • language_detection_mode (Optional[LanguageDetectionMode], default: None ) –

    Enables automatic language identification. Use IDENTIFY_LANGUAGE if your audio contains a single language that you don't know in advance.

    You can optionally include LanguageOptions to limit identification to languages you think may be present, which can improve accuracy.

    Amazon Transcribe returns the identified language, as a locale (for example, en-US), in the response metadata.

    Include either Language or LanguageDetectionMode in your request, but not both.

  • language_options (Optional[SyncLanguageOptions], default: None ) –

    A list of two or more languages that you think may be present in your audio, as base language codes (for example, en and es). Each language can appear only once. A list with only one language returns a BadRequestException.

    You can use LanguageOptions only with LanguageDetectionMode.

  • channel_identification (Optional[Boolean], default: None ) –

    Enables channel identification in multi-channel audio. Each channel is transcribed independently, and each item in the transcript is labeled with its channel.

    Channel identification supports up to two channels.

  • show_speaker_labels (Optional[Boolean], default: None ) –

    Enables speaker partitioning (diarization) in your transcript. Speaker partitioning labels the speech from individual speakers in your media file.

    If you set ShowSpeakerLabels to true, you must also include MaxSpeakerLabels.

    For more information, see Partitioning speakers (diarization).

  • max_speaker_labels (Optional[MaxSpeakers], default: None ) –

    Specify the maximum number of speakers you want to partition in your media.

    Note that if your media contains more speakers than the specified number, Amazon Transcribe treats multiple speakers as a single speaker.

    You can set MaxSpeakerLabels only if ShowSpeakerLabels is true.

  • vocabulary_settings (Optional[VocabularySettingsList], default: None ) –

    Custom vocabularies to apply to your transcript, with one entry per language. In each entry, you can reference a custom vocabulary you created or provide phrases inline. All entries must use the same type, either all by name or all inline.

    If you specify Language, include exactly one entry, and its Language must match. If you use LanguageDetectionMode, you can include one entry for each language in LanguageOptions.

  • vocabulary_filter_settings (Optional[VocabularyFilterSettings], default: None ) –

    Custom vocabulary filters to apply to your transcript, and how to apply them.

  • content_redaction (Optional[ContentRedaction], default: None ) –

    Redacts personally identifiable information (PII) from your transcript. Amazon Transcribe returns the redacted transcript in RedactedResults.

    If you set RedactionOutput to redacted_and_unredacted, Amazon Transcribe also returns the unredacted transcript in Results.

    In Sync, content redaction has these limits:

    • Languages: English (en), Spanish (es), French (fr), Italian (it), German (de), and Portuguese (pt).

    • Language identification: If you use LanguageDetectionMode, you must also include LanguageOptions, and every language in it must be one of the languages above. A request that has no LanguageOptions, or that lists a language that isn't supported, returns a BadRequestException.

    • Regions: Content redaction isn't available in the South America (São Paulo) Region (sa-east-1). It's available in the other Amazon Web Services Regions where Sync is available.

  • output_configuration (Optional[SyncOutputConfiguration], default: None ) –

    Writes the transcript to an Amazon S3 location instead of returning it in the response. If you include OutputConfiguration, the response contains only the output location.

    You must have write permission for the location you specify.

Raises:

  • BadRequestException –

    Your request didn't pass one or more validation tests. This can occur when a parameter has an invalid value, when you combine parameters in a way that isn't supported, when the entity you're trying to delete doesn't exist, or if it's in a non-terminal state (such as IN PROGRESS). See the exception message field for more information.

  • InternalFailureException –

    There was an internal error. Check the error message, correct the issue, and try your request again.

  • LimitExceededException –

    You've either sent too many requests or your input file is too long. Wait before retrying your request, or use a smaller file and try your request again.

  • UnknownServiceError –

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

Source code in docs_src/capo_transcribe/_services/async_transcribe.py
async def transcribe_audio(
    self,
    media: "capo_transcribe.types.sync_media.SyncMedia",
    *,
    config_overrides: Optional[AsyncTranscribeClientConfig] = None,
    language: Optional["capo_transcribe.types.sync_language.SyncLanguage"] = None,
    language_detection_mode: Optional[
        "capo_transcribe.types.language_detection_mode.LanguageDetectionMode"
    ] = None,
    language_options: Optional[
        "capo_transcribe.types.sync_language_options.SyncLanguageOptions"
    ] = None,
    channel_identification: Optional[
        "capo_transcribe.types.boolean.Boolean"
    ] = None,
    show_speaker_labels: Optional["capo_transcribe.types.boolean.Boolean"] = None,
    max_speaker_labels: Optional[
        "capo_transcribe.types.max_speakers.MaxSpeakers"
    ] = None,
    vocabulary_settings: Optional[
        "capo_transcribe.types.vocabulary_settings_list.VocabularySettingsList"
    ] = None,
    vocabulary_filter_settings: Optional[
        "capo_transcribe.types.vocabulary_filter_settings.VocabularyFilterSettings"
    ] = None,
    content_redaction: Optional[
        "capo_transcribe.types.content_redaction.ContentRedaction"
    ] = None,
    output_configuration: Optional[
        "capo_transcribe.types.sync_output_configuration.SyncOutputConfiguration"
    ] = None,
) -> "capo_transcribe.types.transcribe_audio_response.TranscribeAudioResponse":
    """<p>Transcribes a media file and returns the transcript in the same response. There is no job to start and no status to poll.</p> <p>Use <code>TranscribeAudio</code> when you already have a complete media file and want the transcript right away. For large files, long audio, or bulk processing, use .</p> <p>You must include the following parameters in your <code>TranscribeAudio</code> request:</p> <ul> <li> <p> <code>Media</code>: Your audio, either as inline bytes (<code>MediaBytes</code>) or as the Amazon S3 location of a media file (<code>MediaFileUri</code>).</p> </li> <li> <p>One of <code>Language</code> or <code>LanguageDetectionMode</code>: Specify the language of your audio, or have Amazon Transcribe identify it.</p> </li> </ul> <p>Your audio must be between 0.5 seconds and 1 hour long. Supported formats are WAV, MP3, FLAC, M4A, MP4, Ogg, WebM, and AMR.</p> <p>If you send your audio in the request (<code>MediaBytes</code>), the file can be up to 25 MB. If you provide an Amazon S3 location (<code>MediaFileUri</code>), the file can be up to 500 MB.</p> <p>Amazon Transcribe always turns on smart formatting, also known as inverse text normalization (ITN). It writes numbers, dates, currency, and similar items in their usual written form. For example, "one hundred" becomes "100". You can't turn smart formatting off.</p> <p>By default, Amazon Transcribe returns the transcript in <code>TranscriptResponse</code>. If you include <code>OutputConfiguration</code>, Amazon Transcribe writes the transcript to the Amazon S3 location you specify instead, and the response contains only that location.</p>

    Args:
        media: <p>The audio to transcribe. Specify exactly one of <code>MediaBytes</code> or <code>MediaFileUri</code>.</p> <p>Audio sent in the request (<code>MediaBytes</code>) can be up to 25 MB. Audio in Amazon S3 (<code>MediaFileUri</code>) can be up to 500 MB.</p>
        language: <p>The language spoken in your audio, as a base language code (for example, <code>en</code> or <code>es</code>).</p> <p>Include either <code>Language</code> or <code>LanguageDetectionMode</code> in your request, but not both.</p>
        language_detection_mode: <p>Enables automatic language identification. Use <code>IDENTIFY_LANGUAGE</code> if your audio contains a single language that you don't know in advance.</p> <p>You can optionally include <code>LanguageOptions</code> to limit identification to languages you think may be present, which can improve accuracy.</p> <p>Amazon Transcribe returns the identified language, as a locale (for example, <code>en-US</code>), in the response metadata.</p> <p>Include either <code>Language</code> or <code>LanguageDetectionMode</code> in your request, but not both.</p>
        language_options: <p>A list of two or more languages that you think may be present in your audio, as base language codes (for example, <code>en</code> and <code>es</code>). Each language can appear only once. A list with only one language returns a <code>BadRequestException</code>.</p> <p>You can use <code>LanguageOptions</code> only with <code>LanguageDetectionMode</code>.</p>
        channel_identification: <p>Enables channel identification in multi-channel audio. Each channel is transcribed independently, and each item in the transcript is labeled with its channel.</p> <p>Channel identification supports up to two channels.</p>
        show_speaker_labels: <p>Enables speaker partitioning (diarization) in your transcript. Speaker partitioning labels the speech from individual speakers in your media file.</p> <p>If you set <code>ShowSpeakerLabels</code> to <code>true</code>, you must also include <code>MaxSpeakerLabels</code>.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/transcribe/latest/dg/diarization.html">Partitioning speakers (diarization)</a>.</p>
        max_speaker_labels: <p>Specify the maximum number of speakers you want to partition in your media.</p> <p>Note that if your media contains more speakers than the specified number, Amazon Transcribe treats multiple speakers as a single speaker.</p> <p>You can set <code>MaxSpeakerLabels</code> only if <code>ShowSpeakerLabels</code> is <code>true</code>.</p>
        vocabulary_settings: <p>Custom vocabularies to apply to your transcript, with one entry per language. In each entry, you can reference a custom vocabulary you created or provide phrases inline. All entries must use the same type, either all by name or all inline.</p> <p>If you specify <code>Language</code>, include exactly one entry, and its <code>Language</code> must match. If you use <code>LanguageDetectionMode</code>, you can include one entry for each language in <code>LanguageOptions</code>.</p>
        vocabulary_filter_settings: <p>Custom vocabulary filters to apply to your transcript, and how to apply them.</p>
        content_redaction: <p>Redacts personally identifiable information (PII) from your transcript. Amazon Transcribe returns the redacted transcript in <code>RedactedResults</code>.</p> <p>If you set <code>RedactionOutput</code> to <code>redacted_and_unredacted</code>, Amazon Transcribe also returns the unredacted transcript in <code>Results</code>.</p> <p>In Sync, content redaction has these limits:</p> <ul> <li> <p> <b>Languages:</b> English (<code>en</code>), Spanish (<code>es</code>), French (<code>fr</code>), Italian (<code>it</code>), German (<code>de</code>), and Portuguese (<code>pt</code>).</p> </li> <li> <p> <b>Language identification:</b> If you use <code>LanguageDetectionMode</code>, you must also include <code>LanguageOptions</code>, and every language in it must be one of the languages above. A request that has no <code>LanguageOptions</code>, or that lists a language that isn't supported, returns a <code>BadRequestException</code>.</p> </li> <li> <p> <b>Regions:</b> Content redaction isn't available in the South America (São Paulo) Region (<code>sa-east-1</code>). It's available in the other Amazon Web Services Regions where Sync is available.</p> </li> </ul>
        output_configuration: <p>Writes the transcript to an Amazon S3 location instead of returning it in the response. If you include <code>OutputConfiguration</code>, the response contains only the output location.</p> <p>You must have write permission for the location you specify.</p>

    Raises:
        capo_transcribe.errors.bad_request_exception.BadRequestException: <p>Your request didn't pass one or more validation tests. This can occur when a parameter has an invalid value, when you combine parameters in a way that isn't supported, when the entity you're trying to delete doesn't exist, or if it's in a non-terminal state (such as <code>IN PROGRESS</code>). See the exception message field for more information.</p>
        capo_transcribe.errors.internal_failure_exception.InternalFailureException: <p>There was an internal error. Check the error message, correct the issue, and try your request again.</p>
        capo_transcribe.errors.limit_exceeded_exception.LimitExceededException: <p>You've either sent too many requests or your input file is too long. Wait before retrying your request, or use a smaller file and try your request again.</p>
        capo_transcribe.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_transcribe.types.transcribe_audio_request.TranscribeAudioRequest]",
    ) -> AsyncOperationResponse[
        "capo_transcribe.types.transcribe_audio_response.TranscribeAudioResponse"
    ]:
        if req.options.protocol == "awsJson1_1":
            import capo_transcribe._operations.transcribe.aws_json1_1.transcribe_audio

            (
                output,
                http_response,
            ) = await capo_transcribe._operations.transcribe.aws_json1_1.transcribe_audio.async_transcribe_audio(
                req.options, req.input
            )
        elif req.options.protocol == "rpcv2Cbor":
            import capo_transcribe._operations.transcribe.rpcv2_cbor.transcribe_audio

            (
                output,
                http_response,
            ) = await capo_transcribe._operations.transcribe.rpcv2_cbor.transcribe_audio.async_transcribe_audio(
                req.options, req.input
            )
        else:
            raise ValueError(f"unknown protocol {req.options.protocol!r}")
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("TranscribeAudio")
    )
    input_: capo_transcribe.types.transcribe_audio_request.TranscribeAudioRequest = {
        "media": media
    }
    if language is not None:
        input_["language"] = language
    if language_detection_mode is not None:
        input_["language_detection_mode"] = language_detection_mode
    if language_options is not None:
        input_["language_options"] = language_options
    if channel_identification is not None:
        input_["channel_identification"] = channel_identification
    if show_speaker_labels is not None:
        input_["show_speaker_labels"] = show_speaker_labels
    if max_speaker_labels is not None:
        input_["max_speaker_labels"] = max_speaker_labels
    if vocabulary_settings is not None:
        input_["vocabulary_settings"] = vocabulary_settings
    if vocabulary_filter_settings is not None:
        input_["vocabulary_filter_settings"] = vocabulary_filter_settings
    if content_redaction is not None:
        input_["content_redaction"] = content_redaction
    if output_configuration is not None:
        input_["output_configuration"] = output_configuration

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