AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
与 AWS SDK或StartMedicalTranscriptionJob
一起使用 CLI
以下代码示例演示如何使用 StartMedicalTranscriptionJob
。
- .NET
-
- AWS SDK for .NET
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 /// <summary> /// Start a medical transcription job for a media file. This method returns /// as soon as the job is started. /// </summary> /// <param name="jobName">A unique name for the medical transcription job.</param> /// <param name="mediaFileUri">The URI of the media file, typically an Amazon S3 location.</param> /// <param name="mediaFormat">The format of the media file.</param> /// <param name="outputBucketName">Location for the output, typically an Amazon S3 location.</param> /// <param name="transcriptionType">Conversation or dictation transcription type.</param> /// <returns>A MedicalTransactionJob instance with information on the new job.</returns> public async Task<MedicalTranscriptionJob> StartMedicalTranscriptionJob( string jobName, string mediaFileUri, MediaFormat mediaFormat, string outputBucketName, Amazon.TranscribeService.Type transcriptionType) { var response = await _amazonTranscribeService.StartMedicalTranscriptionJobAsync( new StartMedicalTranscriptionJobRequest() { MedicalTranscriptionJobName = jobName, Media = new Media() { MediaFileUri = mediaFileUri }, MediaFormat = mediaFormat, LanguageCode = LanguageCode .EnUS, // The value must be en-US for medical transcriptions. OutputBucketName = outputBucketName, OutputKey = jobName, // The value is a key used to fetch the output of the transcription. Specialty = Specialty.PRIMARYCARE, // The value PRIMARYCARE must be set. Type = transcriptionType }); return response.MedicalTranscriptionJob; }
-
有关API详细信息,请参阅 “AWS SDK for .NET API参考 StartMedicalTranscriptionJob” 中的。
-
- CLI
-
- AWS CLI
-
示例 1:转录存储为音频文件的医疗口述
以下
start-medical-transcription-job
示例转录一个音频文件。您可以在OutputBucketName
参数中指定转录输出位置。aws transcribe start-medical-transcription-job \ --cli-input-json
file://myfile.json
myfile.json
的内容:{ "MedicalTranscriptionJobName": "simple-dictation-medical-transcription-job", "LanguageCode": "language-code", "Specialty": "PRIMARYCARE", "Type": "DICTATION", "OutputBucketName":"DOC-EXAMPLE-BUCKET", "Media": { "MediaFileUri": "s3://DOC-EXAMPLE-BUCKET/your-audio-file.extension" } }
输出:
{ "MedicalTranscriptionJob": { "MedicalTranscriptionJobName": "simple-dictation-medical-transcription-job", "TranscriptionJobStatus": "IN_PROGRESS", "LanguageCode": "language-code", "Media": { "MediaFileUri": "s3://DOC-EXAMPLE-BUCKET/your-audio-file.extension" }, "StartTime": "2020-09-20T00:35:22.256000+00:00", "CreationTime": "2020-09-20T00:35:22.218000+00:00", "Specialty": "PRIMARYCARE", "Type": "DICTATION" } }
有关更多信息,请参阅《Amazon Transcribe 开发人员指南》中的批量转录概述。
示例 2:转录存储为音频文件的临床医生与患者之间的对话
以下
start-medical-transcription-job
示例转录包含有临床医生与患者之间对话的音频文件。您可以在 OutputBucketName 参数中指定转录输出的位置。aws transcribe start-medical-transcription-job \ --cli-input-json
file://mysecondfile.json
mysecondfile.json
的内容:{ "MedicalTranscriptionJobName": "simple-dictation-medical-transcription-job", "LanguageCode": "language-code", "Specialty": "PRIMARYCARE", "Type": "CONVERSATION", "OutputBucketName":"DOC-EXAMPLE-BUCKET", "Media": { "MediaFileUri": "s3://DOC-EXAMPLE-BUCKET/your-audio-file.extension" } }
输出:
{ "MedicalTranscriptionJob": { "MedicalTranscriptionJobName": "simple-conversation-medical-transcription-job", "TranscriptionJobStatus": "IN_PROGRESS", "LanguageCode": "language-code", "Media": { "MediaFileUri": "s3://DOC-EXAMPLE-BUCKET/your-audio-file.extension" }, "StartTime": "2020-09-20T23:19:49.965000+00:00", "CreationTime": "2020-09-20T23:19:49.941000+00:00", "Specialty": "PRIMARYCARE", "Type": "CONVERSATION" } }
有关更多信息,请参阅《Amazon Transcribe 开发人员指南》中的批量转录概述。
示例 3:转录临床医生与患者之间对话的多声道音频文件
以下
start-medical-transcription-job
示例转录音频文件中每个声道的音频,并将每个声道的单独转录合并为一个转录输出。您可以在OutputBucketName
参数中指定转录输出位置。aws transcribe start-medical-transcription-job \ --cli-input-json
file://mythirdfile.json
mythirdfile.json
的内容:{ "MedicalTranscriptionJobName": "multichannel-conversation-medical-transcription-job", "LanguageCode": "language-code", "Specialty": "PRIMARYCARE", "Type": "CONVERSATION", "OutputBucketName":"DOC-EXAMPLE-BUCKET", "Media": { "MediaFileUri": "s3://DOC-EXAMPLE-BUCKET/your-audio-file.extension" }, "Settings":{ "ChannelIdentification": true } }
输出:
{ "MedicalTranscriptionJob": { "MedicalTranscriptionJobName": "multichannel-conversation-medical-transcription-job", "TranscriptionJobStatus": "IN_PROGRESS", "LanguageCode": "language-code", "Media": { "MediaFileUri": "s3://DOC-EXAMPLE-BUCKET/your-audio-file.extension" }, "StartTime": "2020-09-20T23:46:44.081000+00:00", "CreationTime": "2020-09-20T23:46:44.053000+00:00", "Settings": { "ChannelIdentification": true }, "Specialty": "PRIMARYCARE", "Type": "CONVERSATION" } }
有关更多信息,请参阅《Amazon Transcribe 开发人员指南》中的声道识别。
示例 4:转录临床医生与患者之间对话的音频文件并在转录输出中识别发言者
以下
start-medical-transcription-job
示例转录一个音频文件,并在转录输出中标记每个发言者的语音。您可以在OutputBucketName
参数中指定转录输出位置。aws transcribe start-medical-transcription-job \ --cli-input-json
file://myfourthfile.json
myfourthfile.json
的内容:{ "MedicalTranscriptionJobName": "speaker-id-conversation-medical-transcription-job", "LanguageCode": "language-code", "Specialty": "PRIMARYCARE", "Type": "CONVERSATION", "OutputBucketName":"DOC-EXAMPLE-BUCKET", "Media": { "MediaFileUri": "s3://DOC-EXAMPLE-BUCKET/your-audio-file.extension" }, "Settings":{ "ShowSpeakerLabels": true, "MaxSpeakerLabels": 2 } }
输出:
{ "MedicalTranscriptionJob": { "MedicalTranscriptionJobName": "speaker-id-conversation-medical-transcription-job", "TranscriptionJobStatus": "IN_PROGRESS", "LanguageCode": "language-code", "Media": { "MediaFileUri": "s3://DOC-EXAMPLE-BUCKET/your-audio-file.extension" }, "StartTime": "2020-09-21T18:43:37.265000+00:00", "CreationTime": "2020-09-21T18:43:37.157000+00:00", "Settings": { "ShowSpeakerLabels": true, "MaxSpeakerLabels": 2 }, "Specialty": "PRIMARYCARE", "Type": "CONVERSATION" } }
有关更多信息,请参阅《Amazon Transcribe 开发人员指南》中的识别发言者。
示例 5:转录存储为音频文件的医疗对话,最多两个备选转录
以下
start-medical-transcription-job
示例通过单个音频文件创建最多两个备选转录。每个转录具有关联的置信度。默认情况下,Amazon Transcribe 返回置信度最高的转录。您可以指定 Amazon Transcribe 返回置信度较低的其他转录。您可以在OutputBucketName
参数中指定转录输出位置。aws transcribe start-medical-transcription-job \ --cli-input-json
file://myfifthfile.json
myfifthfile.json
的内容:{ "MedicalTranscriptionJobName": "alternatives-conversation-medical-transcription-job", "LanguageCode": "language-code", "Specialty": "PRIMARYCARE", "Type": "CONVERSATION", "OutputBucketName":"DOC-EXAMPLE-BUCKET", "Media": { "MediaFileUri": "s3://DOC-EXAMPLE-BUCKET/your-audio-file.extension" }, "Settings":{ "ShowAlternatives": true, "MaxAlternatives": 2 } }
输出:
{ "MedicalTranscriptionJob": { "MedicalTranscriptionJobName": "alternatives-conversation-medical-transcription-job", "TranscriptionJobStatus": "IN_PROGRESS", "LanguageCode": "language-code", "Media": { "MediaFileUri": "s3://DOC-EXAMPLE-BUCKET/your-audio-file.extension" }, "StartTime": "2020-09-21T19:09:18.199000+00:00", "CreationTime": "2020-09-21T19:09:18.171000+00:00", "Settings": { "ShowAlternatives": true, "MaxAlternatives": 2 }, "Specialty": "PRIMARYCARE", "Type": "CONVERSATION" } }
有关更多信息,请参阅《Amazon Transcribe 开发人员指南》中的备选转录。
示例 6:转录医疗口述音频文件,最多具有两个备选转录
以下
start-medical-transcription-job
示例转录一个音频文件,并使用词汇表过滤器屏蔽任何不需要的单词。您可以在 OutputBucketName 参数中指定转录输出的位置。aws transcribe start-medical-transcription-job \ --cli-input-json
file://mysixthfile.json
mysixthfile.json
的内容:{ "MedicalTranscriptionJobName": "alternatives-conversation-medical-transcription-job", "LanguageCode": "language-code", "Specialty": "PRIMARYCARE", "Type": "DICTATION", "OutputBucketName":"DOC-EXAMPLE-BUCKET", "Media": { "MediaFileUri": "s3://DOC-EXAMPLE-BUCKET/your-audio-file.extension" }, "Settings":{ "ShowAlternatives": true, "MaxAlternatives": 2 } }
输出:
{ "MedicalTranscriptionJob": { "MedicalTranscriptionJobName": "alternatives-dictation-medical-transcription-job", "TranscriptionJobStatus": "IN_PROGRESS", "LanguageCode": "language-code", "Media": { "MediaFileUri": "s3://DOC-EXAMPLE-BUCKET/your-audio-file.extension" }, "StartTime": "2020-09-21T21:01:14.592000+00:00", "CreationTime": "2020-09-21T21:01:14.569000+00:00", "Settings": { "ShowAlternatives": true, "MaxAlternatives": 2 }, "Specialty": "PRIMARYCARE", "Type": "DICTATION" } }
有关更多信息,请参阅《Amazon Transcribe 开发人员指南》中的备选转录。
示例 7:使用自定义词汇表更准确地转录医疗口述音频文件
以下
start-medical-transcription-job
示例转录一个音频文件,并使用您以前创建的医学自定义词汇表提高转录准确性。您可以在OutputBucketName
参数中指定转录输出位置。aws transcribe start-transcription-job \ --cli-input-json
file://myseventhfile.json
mysixthfile.json
的内容:{ "MedicalTranscriptionJobName": "vocabulary-dictation-medical-transcription-job", "LanguageCode": "language-code", "Specialty": "PRIMARYCARE", "Type": "DICTATION", "OutputBucketName":"DOC-EXAMPLE-BUCKET", "Media": { "MediaFileUri": "s3://DOC-EXAMPLE-BUCKET/your-audio-file.extension" }, "Settings":{ "VocabularyName": "cli-medical-vocab-1" } }
输出:
{ "MedicalTranscriptionJob": { "MedicalTranscriptionJobName": "vocabulary-dictation-medical-transcription-job", "TranscriptionJobStatus": "IN_PROGRESS", "LanguageCode": "language-code", "Media": { "MediaFileUri": "s3://DOC-EXAMPLE-BUCKET/your-audio-file.extension" }, "StartTime": "2020-09-21T21:17:27.045000+00:00", "CreationTime": "2020-09-21T21:17:27.016000+00:00", "Settings": { "VocabularyName": "cli-medical-vocab-1" }, "Specialty": "PRIMARYCARE", "Type": "DICTATION" } }
有关更多信息,请参阅《Amazon Transcribe 开发人员指南》中的医疗自定义词汇表。
-
有关API详细信息,请参阅 “StartMedicalTranscriptionJob AWS CLI
命令参考”。
-
- JavaScript
-
- SDK对于 JavaScript (v3)
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 创建客户端。
import { TranscribeClient } from "@aws-sdk/client-transcribe"; // Set the AWS Region. const REGION = "REGION"; //e.g. "us-east-1" // Create an Amazon Transcribe service client object. const transcribeClient = new TranscribeClient({ region: REGION }); export { transcribeClient };
启动医疗转录作业。
// Import the required AWS SDK clients and commands for Node.js import { StartMedicalTranscriptionJobCommand } from "@aws-sdk/client-transcribe"; import { transcribeClient } from "./libs/transcribeClient.js"; // Set the parameters export const params = { MedicalTranscriptionJobName: "MEDICAL_JOB_NAME", // Required OutputBucketName: "OUTPUT_BUCKET_NAME", // Required Specialty: "PRIMARYCARE", // Required. Possible values are 'PRIMARYCARE' Type: "JOB_TYPE", // Required. Possible values are 'CONVERSATION' and 'DICTATION' LanguageCode: "LANGUAGE_CODE", // For example, 'en-US' MediaFormat: "SOURCE_FILE_FORMAT", // For example, 'wav' Media: { MediaFileUri: "SOURCE_FILE_LOCATION", // The S3 object location of the input media file. The URI must be in the same region // as the API endpoint that you are calling.For example, // "https://transcribe-demo.s3-REGION.amazonaws.com/hello_world.wav" }, }; export const run = async () => { try { const data = await transcribeClient.send( new StartMedicalTranscriptionJobCommand(params), ); console.log("Success - put", data); return data; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
-
有关更多信息,请参阅 AWS SDK for JavaScript 开发人员指南。
-
有关API详细信息,请参阅 “AWS SDK for JavaScript API参考 StartMedicalTranscriptionJob” 中的。
-