替代轉錄 - Amazon Transcribe

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

替代轉錄

Amazon Transcribe轉錄音訊時,會建立相同文字稿的不同版本,並為每個版本指派置信度分數。在典型的轉錄中,您只能獲得具有最高可信度分數的版本。

如果您開啟替代轉錄,則會Amazon Transcribe傳回其他可信度較低的成績單版本。您最多可以選擇返回 10 個替代轉錄。如果您指定的替代數量多於Amazon Transcribe標識的數量,則只會返回實際的替代數量。

所有替代方案都位於相同的轉錄輸出檔案中,並在區段層級顯示。區段是語音的自然暫停,例如變更喇叭或音訊暫停。

替代轉錄僅適用於批次轉錄。

您的轉錄輸出的結構如下所示。省略號 (... ) 在程式碼範例中指出為簡潔起見而移除內容的位置。

  1. 給定段的完整最終轉錄。

    "results": { "language_code": "en-US", "transcripts": [ { "transcript": "The amazon is the largest rainforest on the planet." } ],
  2. 前一transcript節中每個單字的置信度分數。

    "items": [ { "start_time": "1.15", "end_time": "1.35", "alternatives": [ { "confidence": "1.0", "content": "The" } ], "type": "pronunciation" }, { "start_time": "1.35", "end_time": "2.05", "alternatives": [ { "confidence": "1.0", "content": "amazon" } ], "type": "pronunciation" },
  3. 您的替代轉錄位於轉錄輸出的segments部分中。每個區段的替代方案是依信賴度分數遞減排序。

    "segments": [ { "start_time": "1.04", "end_time": "5.065", "alternatives": [ { ... "transcript": "The amazon is the largest rain forest on the planet.", "items": [ { "start_time": "1.15", "confidence": "1.0", "end_time": "1.35", "type": "pronunciation", "content": "The" }, ... { "start_time": "3.06", "confidence": "0.0037", "end_time": "3.38", "type": "pronunciation", "content": "rain" }, { "start_time": "3.38", "confidence": "0.0037", "end_time": "3.96", "type": "pronunciation", "content": "forest" },
  4. 轉錄輸出結尾處的狀態。

    "status": "COMPLETED" }

請求替代轉錄

您可以使用AWS Management Console、或 AWSSDK 要求替代轉錄;如需範例 AWS CLI,請參閱下列內容:

  1. 登入 AWS Management Console

  2. 在功能窗格中,選擇「轉錄工作」,然後選取「建立工作」(右上角)。這會開啟 [指定工作詳細資訊] 頁面。

    Amazon Transcribe控制台「指定作業詳細信息」頁面。在「Job 設定」面板中,您可以指定轉錄工作的名稱、選取模型類型,並指定語言設定。
  3. 填寫您要包含在 [指定工作詳細資訊] 頁面上的任何欄位,然後選取 [下一步]。這會帶您前往 [設定工作-選擇性] 頁面。

    選取 [替代結果],然後指定您想要在成績單中輸入的替代轉錄結果數目上限。

    Amazon Transcribe控制台「配置工作」頁面。在「音頻設置」面板中,您可以啟用替代結果,並指定轉錄輸出中要包含的替代方法的最大數量。
  4. 選取 [建立工作] 以執行轉錄工作。

此範例使用指start-transcription-job令和ShowAlternatives參數。如需詳細資訊,請參閱 StartTranscriptionJobShowAlternatives

請注意,如果您ShowAlternatives=true在請求中包含,則還必須包括MaxAlternatives

aws transcribe start-transcription-job \ --region us-west-2 \ --transcription-job-name my-first-transcription-job \ --media MediaFileUri=s3://DOC-EXAMPLE-BUCKET/my-input-files/my-media-file.flac \ --output-bucket-name DOC-EXAMPLE-BUCKET \ --output-key my-output-files/ \ --language-code en-US \ --settings ShowAlternatives=true,MaxAlternatives=4

這是使用start-transcription-job命令的另一個示例,以及包含替代轉錄的請求主體。

aws transcribe start-transcription-job \ --region us-west-2 \ --cli-input-json file://filepath/my-first-alt-transcription-job.json

該文件 my-first-alt-transcription-job.json 包含以下請求主體。

{ "TranscriptionJobName": "my-first-transcription-job", "Media": { "MediaFileUri": "s3://DOC-EXAMPLE-BUCKET/my-input-files/my-media-file.flac" }, "OutputBucketName": "DOC-EXAMPLE-BUCKET", "OutputKey": "my-output-files/", "LanguageCode": "en-US", "Settings": { "ShowAlternatives": true, "MaxAlternatives": 4 } }

下列範例會使用使用 start_transcription_job 方法的ShowAlternatives引數AWS SDK for Python (Boto3)來要求替代轉錄。如需詳細資訊,請參閱 StartTranscriptionJobShowAlternatives

如需使用AWS SDK 的其他範例,包括特定功能、案例和跨服務範例,請參閱本使用 SDK 進行 Amazon Transcribe 的代碼示例 AWS章。

請注意,如果您'ShowAlternatives':True在請求中包含,則還必須包括MaxAlternatives

from __future__ import print_function import time import boto3 transcribe = boto3.client('transcribe', 'us-west-2') job_name = "my-first-transcription-job" job_uri = "s3://DOC-EXAMPLE-BUCKET/my-input-files/my-media-file.flac" transcribe.start_transcription_job( TranscriptionJobName = job_name, Media = { 'MediaFileUri': job_uri }, OutputBucketName = 'DOC-EXAMPLE-BUCKET', OutputKey = 'my-output-files/', LanguageCode = 'en-US', Settings = { 'ShowAlternatives':True, 'MaxAlternatives':4 } ) while True: status = transcribe.get_transcription_job(TranscriptionJobName = job_name) if status['TranscriptionJob']['TranscriptionJobStatus'] in ['COMPLETED', 'FAILED']: break print("Not ready yet...") time.sleep(5) print(status)