startTranscriptionJob method

Future<StartTranscriptionJobResponse> startTranscriptionJob({
  1. required Media media,
  2. required String transcriptionJobName,
  3. ContentRedaction? contentRedaction,
  4. bool? identifyLanguage,
  5. JobExecutionSettings? jobExecutionSettings,
  6. LanguageCode? languageCode,
  7. List<LanguageCode>? languageOptions,
  8. MediaFormat? mediaFormat,
  9. int? mediaSampleRateHertz,
  10. ModelSettings? modelSettings,
  11. String? outputBucketName,
  12. String? outputEncryptionKMSKeyId,
  13. String? outputKey,
  14. Settings? settings,
})

Starts an asynchronous job to transcribe speech to text.

May throw BadRequestException. May throw LimitExceededException. May throw InternalFailureException. May throw ConflictException.

Parameter media : An object that describes the input media for a transcription job.

Parameter transcriptionJobName : The name of the job. You can't use the strings "." or ".." by themselves as the job name. The name must also be unique within an AWS account. If you try to create a transcription job with the same name as a previous transcription job, you get a ConflictException error.

Parameter contentRedaction : An object that contains the request parameters for content redaction.

Parameter identifyLanguage : Set this field to true to enable automatic language identification. Automatic language identification is disabled by default. You receive a BadRequestException error if you enter a value for a LanguageCode.

Parameter jobExecutionSettings : Provides information about how a transcription job is executed. Use this field to indicate that the job can be queued for deferred execution if the concurrency limit is reached and there are no slots available to immediately run the job.

Parameter languageCode : The language code for the language used in the input media file.

Parameter languageOptions : An object containing a list of languages that might be present in your collection of audio files. Automatic language identification chooses a language that best matches the source audio from that list.

Parameter mediaFormat : The format of the input media file.

Parameter mediaSampleRateHertz : The sample rate, in Hertz, of the audio track in the input media file.

If you do not specify the media sample rate, Amazon Transcribe determines the sample rate. If you specify the sample rate, it must match the sample rate detected by Amazon Transcribe. In most cases, you should leave the MediaSampleRateHertz field blank and let Amazon Transcribe determine the sample rate.

Parameter modelSettings : Choose the custom language model you use for your transcription job in this parameter.

Parameter outputBucketName : The location where the transcription is stored.

If you set the OutputBucketName, Amazon Transcribe puts the transcript in the specified S3 bucket. When you call the GetTranscriptionJob operation, the operation returns this location in the TranscriptFileUri field. If you enable content redaction, the redacted transcript appears in RedactedTranscriptFileUri. If you enable content redaction and choose to output an unredacted transcript, that transcript's location still appears in the TranscriptFileUri. The S3 bucket must have permissions that allow Amazon Transcribe to put files in the bucket. For more information, see Permissions Required for IAM User Roles.

You can specify an AWS Key Management Service (KMS) key to encrypt the output of your transcription using the OutputEncryptionKMSKeyId parameter. If you don't specify a KMS key, Amazon Transcribe uses the default Amazon S3 key for server-side encryption of transcripts that are placed in your S3 bucket.

If you don't set the OutputBucketName, Amazon Transcribe generates a pre-signed URL, a shareable URL that provides secure access to your transcription, and returns it in the TranscriptFileUri field. Use this URL to download the transcription.

Parameter outputEncryptionKMSKeyId : The Amazon Resource Name (ARN) of the AWS Key Management Service (KMS) key used to encrypt the output of the transcription job. The user calling the StartTranscriptionJob operation must have permission to use the specified KMS key.

You can use either of the following to identify a KMS key in the current account:

  • KMS Key ID: "1234abcd-12ab-34cd-56ef-1234567890ab"
  • KMS Key Alias: "alias/ExampleAlias"
You can use either of the following to identify a KMS key in the current account or another account:
  • Amazon Resource Name (ARN) of a KMS Key: "arn:aws:kms:region:account ID:key/1234abcd-12ab-34cd-56ef-1234567890ab"
  • ARN of a KMS Key Alias: "arn:aws:kms:region:account ID:alias/ExampleAlias"
If you don't specify an encryption key, the output of the transcription job is encrypted with the default Amazon S3 key (SSE-S3).

If you specify a KMS key to encrypt your output, you must also specify an output location in the OutputBucketName parameter.

Parameter outputKey : You can specify a location in an Amazon S3 bucket to store the output of your transcription job.

If you don't specify an output key, Amazon Transcribe stores the output of your transcription job in the Amazon S3 bucket you specified. By default, the object key is "your-transcription-job-name.json".

You can use output keys to specify the Amazon S3 prefix and file name of the transcription output. For example, specifying the Amazon S3 prefix, "folder1/folder2/", as an output key would lead to the output being stored as "folder1/folder2/your-transcription-job-name.json". If you specify "my-other-job-name.json" as the output key, the object key is changed to "my-other-job-name.json". You can use an output key to change both the prefix and the file name, for example "folder/my-other-job-name.json".

If you specify an output key, you must also specify an S3 bucket in the OutputBucketName parameter.

Parameter settings : A Settings object that provides optional settings for a transcription job.

Implementation

Future<StartTranscriptionJobResponse> startTranscriptionJob({
  required Media media,
  required String transcriptionJobName,
  ContentRedaction? contentRedaction,
  bool? identifyLanguage,
  JobExecutionSettings? jobExecutionSettings,
  LanguageCode? languageCode,
  List<LanguageCode>? languageOptions,
  MediaFormat? mediaFormat,
  int? mediaSampleRateHertz,
  ModelSettings? modelSettings,
  String? outputBucketName,
  String? outputEncryptionKMSKeyId,
  String? outputKey,
  Settings? settings,
}) async {
  ArgumentError.checkNotNull(media, 'media');
  ArgumentError.checkNotNull(transcriptionJobName, 'transcriptionJobName');
  _s.validateStringLength(
    'transcriptionJobName',
    transcriptionJobName,
    1,
    200,
    isRequired: true,
  );
  _s.validateNumRange(
    'mediaSampleRateHertz',
    mediaSampleRateHertz,
    8000,
    48000,
  );
  _s.validateStringLength(
    'outputBucketName',
    outputBucketName,
    0,
    64,
  );
  _s.validateStringLength(
    'outputEncryptionKMSKeyId',
    outputEncryptionKMSKeyId,
    1,
    2048,
  );
  _s.validateStringLength(
    'outputKey',
    outputKey,
    1,
    1024,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Transcribe.StartTranscriptionJob'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Media': media,
      'TranscriptionJobName': transcriptionJobName,
      if (contentRedaction != null) 'ContentRedaction': contentRedaction,
      if (identifyLanguage != null) 'IdentifyLanguage': identifyLanguage,
      if (jobExecutionSettings != null)
        'JobExecutionSettings': jobExecutionSettings,
      if (languageCode != null) 'LanguageCode': languageCode.toValue(),
      if (languageOptions != null)
        'LanguageOptions': languageOptions.map((e) => e.toValue()).toList(),
      if (mediaFormat != null) 'MediaFormat': mediaFormat.toValue(),
      if (mediaSampleRateHertz != null)
        'MediaSampleRateHertz': mediaSampleRateHertz,
      if (modelSettings != null) 'ModelSettings': modelSettings,
      if (outputBucketName != null) 'OutputBucketName': outputBucketName,
      if (outputEncryptionKMSKeyId != null)
        'OutputEncryptionKMSKeyId': outputEncryptionKMSKeyId,
      if (outputKey != null) 'OutputKey': outputKey,
      if (settings != null) 'Settings': settings,
    },
  );

  return StartTranscriptionJobResponse.fromJson(jsonResponse.body);
}