### Basic Amazon Transcribe Job Setup (Python) Source: https://docs.aws.amazon.com/transcribe/latest/dg/example_transcribe_Scenario_CustomVocabulary_section.md Sets up and starts a basic transcription job without a custom vocabulary. This example demonstrates the initial steps for transcribing audio files stored in S3. ```python def usage_demo(): """Shows how to use the Amazon Transcribe service.""" logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s") s3_resource = boto3.resource("s3") transcribe_client = boto3.client("transcribe") print("-" * 88) print("Welcome to the Amazon Transcribe demo!") print("-" * 88) bucket_name = f"jabber-bucket-{time.time_ns()}" print(f"Creating bucket {bucket_name}.") bucket = s3_resource.create_bucket( Bucket=bucket_name, CreateBucketConfiguration={ "LocationConstraint": transcribe_client.meta.region_name }, ) media_file_name = ".media/Jabberwocky.mp3" media_object_key = "Jabberwocky.mp3" print(f"Uploading media file {media_file_name}.") bucket.upload_file(media_file_name, media_object_key) media_uri = f"s3://{bucket.name}/{media_object_key}" job_name_simple = f"Jabber-{time.time_ns()}" print(f"Starting transcription job {job_name_simple}.") start_job( job_name_simple, f"s3://{bucket_name}/{media_object_key}", "mp3", "en-US", transcribe_client, ) transcribe_waiter = TranscribeCompleteWaiter(transcribe_client) transcribe_waiter.wait(job_name_simple) job_simple = get_job(job_name_simple, transcribe_client) transcript_simple = requests.get( job_simple["Transcript"]["TranscriptFileUri"] ).json() print(f"Transcript for job {transcript_simple['jobName']}:") print(transcript_simple["results"]["transcripts"][0]["transcript"]) print("-" * 88) print( ``` -------------------------------- ### Start transcription job with alternative results (AWS SDK for Python) Source: https://docs.aws.amazon.com/transcribe/latest/dg/how-alternatives.html Use the Boto3 SDK to start a transcription job and request alternative transcriptions. This example includes logic to poll the job status until completion. ```python 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://amzn-s3-demo-bucket/my-input-files/my-media-file.flac" transcribe.start_transcription_job( TranscriptionJobName = job_name, Media = { 'MediaFileUri': job_uri }, OutputBucketName = 'amzn-s3-demo-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) ``` -------------------------------- ### Start Transcription Job with Subtitles (AWS CLI) Source: https://docs.aws.amazon.com/transcribe/latest/dg/subtitles.md This example demonstrates how to start a transcription job and specify subtitle generation using the AWS CLI. It includes options for specifying subtitle formats and the starting index. ```APIDOC ## start-transcription-job with Subtitles (AWS CLI) ### Description Starts an Amazon Transcribe job and configures it to generate subtitles in specified formats. ### Method `aws transcribe start-transcription-job` ### Parameters - `--region` (string) - Required - The AWS region to use. - `--transcription-job-name` (string) - Required - A unique name for the transcription job. - `--media` (string) - Required - Specifies the media source, including `MediaFileUri`. - `--output-bucket-name` (string) - Required - The S3 bucket to store the output. - `--output-key` (string) - Required - The S3 key prefix for the output. - `--language-code` (string) - Required - The language code of the audio. - `--subtitles` (string) - Optional - Configuration for subtitle generation. Includes `Formats` (e.g., `vtt`, `srt`) and `OutputStartIndex`. ### Request Example (CLI Command) ```bash aws transcribe start-transcription-job \ --region {{us-west-2}} \ --transcription-job-name {{my-first-transcription-job}} \ --media MediaFileUri=s3://{{amzn-s3-demo-bucket}}/{{my-input-files}}/{{my-media-file}}.{{flac}} \ --output-bucket-name {{amzn-s3-demo-bucket}} \ --output-key {{my-output-files}}/ \ --language-code {{en-US}} \ --subtitles Formats={{vtt}},{{srt}},OutputStartIndex={{1}} ``` ### Request Example (JSON Input File) *my-first-subtitle-job.json* ```json { "TranscriptionJobName": "{{my-first-transcription-job}}", "Media": { "MediaFileUri": "s3://{{amzn-s3-demo-bucket}}/{{my-input-files}}/{{my-media-file}}.{{flac}}" }, "OutputBucketName": "{{amzn-s3-demo-bucket}}", "OutputKey": "{{my-output-files}}/", "LanguageCode": "{{en-US}}", "Subtitles": { "Formats": [ "{{vtt}}","{{srt}}" ], "OutputStartIndex": {{1}} } } ``` ### Response (Details on response structure can be found in the AWS Transcribe API documentation) ``` -------------------------------- ### StartTranscriptionJob HTTP Request Source: https://docs.aws.amazon.com/transcribe/latest/dg/getting-started-http-websocket.md Use this example for a batch HTTP request to start a transcription job. Ensure all placeholder values are replaced with your specific details. ```http POST /transcribe HTTP/1.1 host: transcribe.{{us-west-2}}.amazonaws.com x-amz-target: com.amazonaws.transcribe.Transcribe.{{StartTranscriptionJob}} content-type: application/x-amz-json-1.1 x-amz-content-sha256: {{string}} x-amz-date: {{YYYYMMDD}}T{{HHMMSS}}Z authorization: AWS4-HMAC-SHA256 Credential={{access-key}}/{{YYYYMMSS}}/{{us-west-2}}/transcribe/aws4_request, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target;x-amz-security-token, Signature={{string}} { "TranscriptionJobName": "{{my-first-transcription-job}}", "LanguageCode": "{{en-US}}", "Media": { "MediaFileUri": "s3://{{amzn-s3-demo-bucket}}/{{my-input-files}}/{{my-media-file}}.{{flac}}" }, "OutputBucketName": "{{amzn-s3-demo-bucket}}", "OutputKey": "{{my-output-files}}/" } ``` -------------------------------- ### Start Transcription Job - Multi-channel Identification Source: https://docs.aws.amazon.com/transcribe/latest/dg/example_transcribe_StartTranscriptionJob_section.md This example transcribes a multi-channel audio file and enables channel identification. Configure the 'Settings' block with 'ChannelIdentification' set to true. ```bash aws transcribe start-transcription-job \ --cli-input-json {{file://mysecondfile.json}} ``` ```json { "TranscriptionJobName": "cli-channelid-job", "LanguageCode": "the-language-of-your-transcription-job", "Media": { "MediaFileUri": "s3://amzn-s3-demo-bucket/Amazon-S3-prefix/your-media-file-name.file-extension" }, "Settings":{ "ChannelIdentification":true } } ``` ```json { "TranscriptionJob": { "TranscriptionJobName": "cli-channelid-job", "TranscriptionJobStatus": "IN_PROGRESS", "LanguageCode": "the-language-of-your-transcription-job", "Media": { "MediaFileUri": "s3://amzn-s3-demo-bucket/Amazon-S3-prefix/your-media-file-name.file-extension" }, "StartTime": "2020-09-17T16:07:56.817000+00:00", "CreationTime": "2020-09-17T16:07:56.784000+00:00", "Settings": { "ChannelIdentification": true } } } ``` -------------------------------- ### Audio Input and Recording Setup Source: https://docs.aws.amazon.com/transcribe/latest/dg/health-scribe-streaming-setting-up.md Configures audio input, starts recording, and sets up a thread to monitor for the Enter key to stop recording. This is used to capture audio data for streaming. ```java int bufferSize = (CHUNK_SIZE_IN_BYTES / format.getFrameSize()) * format.getFrameSize(); line.open(format); line.start(); // Create a wrapper class that can be closed when Enter is pressed AudioInputStream audioStream = new AudioInputStream(line); // Start a thread to monitor for Enter key System.out.println("Recording... Press Enter to stop"); Thread monitorThread = new Thread(() -> { try { System.in.read(); line.stop(); line.close(); } catch (IOException e) { e.printStackTrace(); } }); monitorThread.setDaemon(true); // Set as daemon thread so it doesn't prevent JVM shutdown monitorThread.start(); return new AudioInputStream( new BufferedInputStream(new AudioInputStream(line)), format, AudioSystem.NOT_SPECIFIED ); ``` -------------------------------- ### StartTranscriptionJob SDK Example Source: https://docs.aws.amazon.com/transcribe/latest/dg/example_transcribe_StartTranscriptionJob_section.md This code snippet demonstrates how to start a transcription job using the AWS SDK for SAP ABAP. It includes error handling for various exceptions. ```APIDOC ## StartTranscriptionJob ### Description Starts an asynchronous transcription job from an audio file. ### Method `startTranscriptionJob` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **iv_transcriptionjobname** (string) - Required - The name of the transcription job. - **io_media** (/aws1/cl_tnbmedia) - Required - An object containing the URI of the media file. - **iv_mediaformat** (string) - Required - The format of the media file (e.g., 'mp3', 'wav'). - **iv_languagecode** (string) - Required - The language code of the audio (e.g., 'en-US'). - **io_settings** (/aws1/cl_tnbsettings) - Optional - Settings for the transcription job, such as vocabulary name. ### Request Example ```abap TRY. DATA(lo_media) = NEW /aws1/cl_tnbmedia( iv_mediafileuri = iv_media_uri ). DATA(lo_settings) = NEW /aws1/cl_tnbsettings( ). IF iv_vocabulary_name IS NOT INITIAL. lo_settings = NEW /aws1/cl_tnbsettings( iv_vocabularyname = iv_vocabulary_name ). ENDIF. oo_result = lo_tnb->starttranscriptionjob( iv_transcriptionjobname = iv_job_name io_media = lo_media iv_mediaformat = iv_media_format iv_languagecode = iv_language_code io_settings = lo_settings ). MESSAGE 'Transcription job started.' TYPE 'I'. CATCH /aws1/cx_tnbbadrequestex INTO DATA(lo_bad_request_ex). MESSAGE lo_bad_request_ex TYPE 'I'. RAISE EXCEPTION lo_bad_request_ex. CATCH /aws1/cx_tnblimitexceededex INTO DATA(lo_limit_ex). MESSAGE lo_limit_ex TYPE 'I'. RAISE EXCEPTION lo_limit_ex. CATCH /aws1/cx_tnbinternalfailureex INTO DATA(lo_internal_ex). MESSAGE lo_internal_ex TYPE 'I'. RAISE EXCEPTION lo_internal_ex. CATCH /aws1/cx_tnbconflictexception INTO DATA(lo_conflict_ex). MESSAGE lo_conflict_ex TYPE 'I'. RAISE EXCEPTION lo_conflict_ex. ENDTRY. ``` ### Response #### Success Response (200) - **oo_result** - The result of the `starttranscriptionjob` operation. #### Response Example (Response details not provided in source text) ``` -------------------------------- ### Start Transcription Job using AWS SDK for JavaScript Source: https://docs.aws.amazon.com/transcribe/latest/dg/example_transcribe_StartTranscriptionJob_section.md Initiates a transcription job using the AWS SDK for JavaScript (v3). This example demonstrates setting up the client and parameters to start a job. ```APIDOC ## StartTranscriptionJob (JavaScript SDK v3) ### Description Starts an asynchronous transcription job from an audio source. ### Method `StartTranscriptionJobCommand` ### Parameters #### Request Body Parameters - **TranscriptionJobName** (string) - Required - The name of the transcription job. Must be unique. - **LanguageCode** (string) - Required - The language code of the audio (e.g., 'en-US'). - **MediaFormat** (string) - Required - The format of the media file (e.g., 'wav'). - **Media** (object) - Required - Contains the URI of the media file. - **MediaFileUri** (string) - Required - The S3 URI of the media file. - **OutputBucketName** (string) - Required - The name of the S3 bucket where the transcription output will be stored. ### Request Example ```javascript // Import the required AWS SDK clients and commands for Node.js import { StartTranscriptionJobCommand } from "@aws-sdk/client-transcribe"; import { transcribeClient } from "./libs/transcribeClient.js"; // Set the parameters export const params = { TranscriptionJobName: "JOB_NAME", LanguageCode: "LANGUAGE_CODE", // For example, 'en-US' MediaFormat: "SOURCE_FILE_FORMAT", // For example, 'wav' Media: { MediaFileUri: "SOURCE_LOCATION", // For example, "https://transcribe-demo.s3-REGION.amazonaws.com/hello_world.wav" }, OutputBucketName: "OUTPUT_BUCKET_NAME", }; export const run = async () => { try { const data = await transcribeClient.send( new StartTranscriptionJobCommand(params), ); console.log("Success - put", data); return data; // For unit tests. } catch (err) { console.log("Error", err); } }; run(); ``` ### Response #### Success Response (200) Returns details about the initiated transcription job. ``` -------------------------------- ### Start Stream Transcription with Speaker Labels (HTTP/2) Source: https://docs.aws.amazon.com/transcribe/latest/dg/diarization.md This example shows how to construct an HTTP/2 request to initiate a streaming transcription with speaker partitioning enabled. It details the necessary headers and target endpoint. ```APIDOC ## Partitioning speakers in a streaming transcription ### HTTP/2 stream This example creates an HTTP/2 request that partitions speakers in your transcription output. For more information on using HTTP/2 streaming with Amazon Transcribe, see [Setting up an HTTP/2 stream](streaming-setting-up.md#streaming-http2). For more detail on parameters and headers specific to Amazon Transcribe, see [StartStreamTranscription](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartStreamTranscription.html). ### Method ```http POST /stream-transcription HTTP/2 host: transcribestreaming.{{us-west-2}}.amazonaws.com X-Amz-Target: com.amazonaws.transcribe.Transcribe.{{StartStreamTranscription}} Content-Type: application/vnd.amazon.eventstream X-Amz-Content-Sha256: {{string}} X-Amz-Date: {{20220208}}T{{235959}}Z Authorization: AWS4-HMAC-SHA256 Credential={{access-key}}/{{20220208}}/{{us-west-2}}/transcribe/aws4_request, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target;x-amz-security-token, Signature={{string}} x-amzn-transcribe-language-code: {{en-US}} x-amzn-transcribe-media-encoding: {{flac}} x-amzn-transcribe-sample-rate: {{16000}} x-amzn-transcribe-show-speaker-label: true transfer-encoding: chunked ``` Parameter definitions can be found in the [API Reference](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_Reference.html); parameters common to all AWS API operations are listed in the [Common Parameters](https://docs.aws.amazon.com/transcribe/latest/APIReference/CommonParameters.html) section. ``` -------------------------------- ### Start HealthScribe Job using AWS SDK for Python (Boto3) Source: https://docs.aws.amazon.com/transcribe/latest/dg/starting-health-scribe-job.md Use Boto3 to programmatically start an AWS HealthScribe transcription job. This example demonstrates setting up the client, defining job parameters, and includes a loop to check job status. ```python from __future__ import print_functionimport timeimport boto3 transcribe = boto3.client('transcribe', '{{us-west-2}}') job_name = "{{my-first-medical-scribe-job}}" job_uri = "{{s3://amzn-s3-demo-bucket/my-input-files/my-media-file.flac}}" transcribe.start_medical_scribe_job( MedicalScribeJobName = job_name, Media = { 'MediaFileUri': job_uri }, OutputBucketName = '{{amzn-s3-demo-bucket}}', DataAccessRoleArn = '{{arn:aws:iam::111122223333:role/ExampleRole}}', Settings = { 'ShowSpeakerLabels': false, 'ChannelIdentification': true }, ChannelDefinitions = [ { 'ChannelId': 0, 'ParticipantRole': 'CLINICIAN' }, { 'ChannelId': 1, 'ParticipantRole': 'PATIENT' } ] ) while True: status = transcribe.get_medical_scribe_job(MedicalScribeJobName = job_name) if status['MedicalScribeJob']['MedicalScribeJobStatus'] in ['COMPLETED', 'FAILED']: break print("Not ready yet...") time.sleep(5) print(status) ``` -------------------------------- ### AWS CLI - Start Call Analytics Job Source: https://docs.aws.amazon.com/transcribe/latest/dg/tca-start-batch.md This example demonstrates how to start a post-call analytics transcription job using the AWS CLI, specifying media input, output location, IAM role, and channel definitions. ```APIDOC ## AWS CLI This example uses the [start-call-analytics-job](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/transcribe/start-call-analytics-job.html) command and `channel-definitions` parameter. For more information, see [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartCallAnalyticsJob.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartCallAnalyticsJob.html) and [https://docs.aws.amazon.com/transcribe/latest/APIReference/API_ChannelDefinition.html](https://docs.aws.amazon.com/transcribe/latest/APIReference/API_ChannelDefinition.html). ``` aws transcribe start-call-analytics-job \ --region {{us-west-2}} \ --call-analytics-job-name {{my-first-call-analytics-job}} \ --media MediaFileUri=s3://{{amzn-s3-demo-bucket}}/{{my-input-files}}/{{my-media-file}}.{{flac}} \ --output-location s3://{{amzn-s3-demo-bucket}}/{{my-output-files}}/ \ --data-access-role-arn arn:aws:iam::{{111122223333}}:role/{{ExampleRole}} \ --channel-definitions ChannelId=0,ParticipantRole={{AGENT}} ChannelId=1,ParticipantRole={{CUSTOMER}} ``` Here's another example using the [start-call-analytics-job](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/transcribe/start-call-analytics-job.html) command, and a request body that enables Call Analytics for that job. ``` aws transcribe start-call-analytics-job \ --region {{us-west-2}} \ --cli-input-json file://{{filepath}}/{{my-call-analytics-job}}.json ``` The file *my-call-analytics-job.json* contains the following request body. ```json { "CallAnalyticsJobName": "{{my-first-call-analytics-job}}", "DataAccessRoleArn": "arn:aws:iam::{{111122223333}}:role/{{ExampleRole}}", "Media": { "MediaFileUri": "s3://{{amzn-s3-demo-bucket}}/{{my-input-files}}/{{my-media-file}}.{{flac}}" }, "OutputLocation": "s3://{{amzn-s3-demo-bucket}}/{{my-output-files}}/", "ChannelDefinitions": [ { "ChannelId": 0, "ParticipantRole": "{{AGENT}}" }, { "ChannelId": 1, "ParticipantRole": "{{CUSTOMER}}" } ] } ``` ``` -------------------------------- ### Start Transcription Job with Alternative Transcriptions (AWS CLI) Source: https://docs.aws.amazon.com/transcribe/latest/dg/alternative-med-transcriptions.md This example shows how to use the AWS CLI to start a transcription job that generates alternative transcriptions. It uses a JSON file to define the job parameters, including enabling alternative results and setting the maximum number of alternatives. ```APIDOC ## Start Transcription Job with Alternative Transcriptions (AWS CLI) ### Description Starts a transcription job using the AWS CLI and a JSON configuration file to enable alternative transcriptions. ### Method `aws transcribe start-transcription-job` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body This command uses a JSON file for its parameters. The following shows the contents of `example-start-command.json`: - **MedicalTranscriptionJobName** (string) - Required - A name that is unique in your AWS account. - **LanguageCode** (string) - Required - The language code for the language spoken in your audio file. - **Specialty** (string) - Required - The medical specialty of the clinician speaking in the audio file. - **Type** (string) - Required - Whether you're transcribing a medical conversation or a dictation. - **OutputBucketName** (string) - Required - The Amazon S3 bucket to store the transcription results. - **Media** (object) - Required - The media format and location of the audio file. - **MediaFileUri** (string) - Required - The location of the audio file you want to transcribe. - **Settings** (object) - Optional - Configuration settings for the transcription job. - **ShowAlternatives** (boolean) - Required - Set to `true` to generate alternative transcriptions. - **MaxAlternatives** (integer) - Optional - An integer between 2 and 10 to indicate the number of alternative transcriptions you want in the transcription output. ### Request Example ```bash aws transcribe start-transcription-job \ --cli-input-json file://{{filepath}}/{{example-start-command}}.json ``` ```json { "MedicalTranscriptionJobName": "{{my-first-transcription-job}}", "LanguageCode": "en-US", "Specialty": "PRIMARYCARE", "Type": "CONVERSATION", "OutputBucketName":"{{amzn-s3-demo-bucket}}", "Media": { "MediaFileUri": "s3://{{amzn-s3-demo-bucket}}/{{my-input-files}}/{{my-audio-file}}.{{flac}}" }, "Settings":{ "ShowAlternatives": true, "MaxAlternatives": 2 } } ``` ### Response #### Success Response (200) Returns the status of the transcription job. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Start Medical Transcription Job with Alternative Transcriptions (AWS SDK for Python) Source: https://docs.aws.amazon.com/transcribe/latest/dg/alternative-med-transcriptions.md This example demonstrates how to use the AWS SDK for Python (Boto3) to start a medical transcription job that generates up to two alternative transcriptions. It configures the job to show alternatives and specifies the maximum number of alternatives. ```APIDOC ## StartMedicalTranscriptionJob with Alternative Transcriptions ### Description Starts a medical transcription job and configures it to return alternative transcriptions. ### Method `StartMedicalTranscriptionJob` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **MedicalTranscriptionJobName** (string) - Required - A name that is unique in your AWS account. - **Media** (object) - Required - The media format and location of the audio file. - **MediaFileUri** (string) - Required - The location of the audio file you want to transcribe. - **OutputBucketName** (string) - Required - The Amazon S3 bucket to store the transcription results. - **OutputKey** (string) - Optional - The S3 key prefix for the transcription results. - **LanguageCode** (string) - Required - The language code for the language spoken in your audio file. - **Specialty** (string) - Required - The medical specialty of the clinician speaking in the audio file. - **Type** (string) - Required - Whether you're transcribing a medical conversation or a dictation. - **Settings** (object) - Optional - Configuration settings for the transcription job. - **ShowAlternatives** (boolean) - Required - Set to `true` to generate alternative transcriptions. - **MaxAlternatives** (integer) - Optional - An integer between 2 and 10 to indicate the number of alternative transcriptions you want in the transcription output. ### Request Example ```python 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://{{amzn-s3-demo-bucket}}/{{my-input-files}}/{{my-audio-file}}.{{flac}} transcribe.start_medical_transcription_job( MedicalTranscriptionJobName = job_name, Media = { 'MediaFileUri': job_uri }, OutputBucketName = '{{amzn-s3-demo-bucket}}', OutputKey = '{{my-output-files}}/', LanguageCode = 'en-US', Specialty = 'PRIMARYCARE', Type = '{{CONVERSATION}}', Settings = { 'ShowAlternatives': True, 'MaxAlternatives': 2 } ) while True: status = transcribe.get_medical_transcription_job(MedicalTranscriptionJobName = job_name) if status['MedicalTranscriptionJob']['TranscriptionJobStatus'] in ['COMPLETED', 'FAILED']: break print("Not ready yet...") time.sleep(5) print(status) ``` ### Response #### Success Response (200) Returns the status of the transcription job. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Start Transcription Job with Alternatives (AWS CLI) Source: https://docs.aws.amazon.com/transcribe/latest/dg/alternatives.md Use the `start-transcription-job` command with `ShowAlternatives=true` and `MaxAlternatives` to get alternative transcriptions. Ensure `MaxAlternatives` is set when `ShowAlternatives` is enabled. ```bash aws transcribe start-transcription-job \ --region {{us-west-2}} \ --transcription-job-name {{my-first-transcription-job}} \ --media MediaFileUri=s3://{{amzn-s3-demo-bucket}}/{{my-input-files}}/{{my-media-file}}.{{flac}} \ --output-bucket-name {{amzn-s3-demo-bucket}} \ --output-key {{my-output-files}}/ \ --language-code {{en-US}} \ --settings ShowAlternatives=true,MaxAlternatives={{4}} ``` -------------------------------- ### Start Call Analytics WebSocket Stream Source: https://docs.aws.amazon.com/transcribe/latest/dg/tca-start-stream.md Use this example to create a presigned URL for a WebSocket stream with Call Analytics. Ensure the configuration event is sent as the first event in the stream. Remove PostCallAnalyticsSettings if not needed. ```http GET wss://transcribestreaming.{{us-west-2}}.amazonaws.com:8443/call-analytics-stream-transcription-websocket? &X-Amz-Algorithm=AWS4-HMAC-SHA256 &X-Amz-Credential={{AKIAIOSFODNN7EXAMPLE}}%2F{{20220208}}%2F{{us-west-2}}%2F{{transcribe}}%2Faws4_request &X-Amz-Date={{20220208}}T{{235959}}Z &X-Amz-Expires={{300}} &X-Amz-Security-Token={{security-token}} &X-Amz-Signature={{string}} &X-Amz-SignedHeaders=content-type%3Bhost%3Bx-amz-date &language-code={{en-US}} &media-encoding={{flac}} &sample-rate={{16000}} { "AudioStream": { "AudioEvent": { "AudioChunk": blob }, "ConfigurationEvent": { "ChannelDefinitions": [ { "ChannelId": {{0}}, "ParticipantRole": "{{AGENT}}" }, { "ChannelId": {{1}}, "ParticipantRole": "{{CUSTOMER}}" } ], "PostCallAnalyticsSettings": { "OutputLocation": "s3://{{amzn-s3-demo-bucket}}/{{my-output-files}}/", "DataAccessRoleArn": "arn:aws:iam::{{111122223333}}:role/{{ExampleRole}}" } } } } ``` -------------------------------- ### Start Transcription Job with Channel Identification (AWS CLI) Source: https://docs.aws.amazon.com/transcribe/latest/dg/channel-id.md This example demonstrates how to start a transcription job using the AWS CLI and enable channel identification by setting the `ChannelIdentification` parameter to `true` in the command or in a JSON input file. ```APIDOC ## Start Transcription Job with Channel Identification (AWS CLI) ### Description This example demonstrates how to start a transcription job using the AWS CLI and enable channel identification by setting the `ChannelIdentification` parameter to `true` in the command or in a JSON input file. ### Method `aws transcribe start-transcription-job` ### Endpoint N/A (AWS CLI command) ### Parameters #### Command Line Parameters - `--region` (string) - Required - The AWS region to use. - `--transcription-job-name` (string) - Required - The name of the transcription job. - `--media` (structure) - Required - The media format and location. - `MediaFileUri` (string) - Required - The S3 URI of the media file. - `--output-bucket-name` (string) - Required - The name of the S3 bucket for output. - `--output-key` (string) - Optional - The S3 key prefix for output files. - `--language-code` (string) - Required - The language code for the transcription. - `--settings` (structure) - Optional - Settings for the transcription job. - `ChannelIdentification` (boolean) - Required - Set to `true` to enable channel identification. ### Request Example (Command Line) ```bash aws transcribe start-transcription-job \ --region {{us-west-2}} \ --transcription-job-name {{my-first-transcription-job}} \ --media MediaFileUri=s3://{{amzn-s3-demo-bucket}}/{{my-input-files}}/{{my-media-file}}.{{flac}} \ --output-bucket-name {{amzn-s3-demo-bucket}} \ --output-key {{my-output-files}}/ \ --language-code {{en-US}} \ --settings '{"ChannelIdentification":true}' ``` ### Request Example (JSON File) ```json { "TranscriptionJobName": "{{my-first-transcription-job}}", "Media": { "MediaFileUri": "s3://{{amzn-s3-demo-bucket}}/{{my-input-files}}/{{my-media-file}}.{{flac}}" }, "OutputBucketName": "{{amzn-s3-demo-bucket}}", "OutputKey": "{{my-output-files}}/", "LanguageCode": "{{en-US}}", "Settings": { "ChannelIdentification": true } } ``` ### Response (Details depend on the `start-transcription-job` API response structure, which is not fully detailed here but typically includes job status and output locations.) ``` -------------------------------- ### Start Transcription Job - Speaker Identification Source: https://docs.aws.amazon.com/transcribe/latest/dg/example_transcribe_StartTranscriptionJob_section.md This example transcribes an audio file and identifies different speakers. Set 'ShowSpeakerLabels' to true and optionally specify 'MaxSpeakerLabels' in the 'Settings' block. ```bash aws transcribe start-transcription-job \ --cli-input-json {{file://mythirdfile.json}} ``` ```json { "TranscriptionJobName": "cli-speakerid-job", "LanguageCode": "the-language-of-your-transcription-job", "Media": { "MediaFileUri": "s3://amzn-s3-demo-bucket/Amazon-S3-prefix/your-media-file-name.file-extension" }, "Settings":{ "ShowSpeakerLabels": true, "MaxSpeakerLabels": 2 } } ``` ```json { "TranscriptionJob": { "TranscriptionJobName": "cli-speakerid-job", "TranscriptionJobStatus": "IN_PROGRESS", "LanguageCode": "the-language-of-your-transcription-job", "Media": { "MediaFileUri": "s3://amzn-s3-demo-bucket/Amazon-S3-prefix/your-media-file-name.file-extension" }, "StartTime": "2020-09-17T16:22:59.696000+00:00", "CreationTime": "2020-09-17T16:22:59.676000+00:00", "Settings": { "ShowSpeakerLabels": true, "MaxSpeakerLabels": 2 } } } ``` -------------------------------- ### Start Stream Transcription with Channel Identification (HTTP/2) Source: https://docs.aws.amazon.com/transcribe/latest/dg/channel-id.md This example shows how to initiate a streaming transcription with channel identification enabled using an HTTP/2 request. It highlights the necessary headers, including `x-amzn-channel-identification: TRUE`. ```APIDOC ## Start Stream Transcription with Channel Identification (HTTP/2) ### Description This example shows how to initiate a streaming transcription with channel identification enabled using an HTTP/2 request. It highlights the necessary headers, including `x-amzn-channel-identification: TRUE`. ### Method `POST` ### Endpoint `/stream-transcription` ### Headers - `host`: `transcribestreaming.{{us-west-2}}.amazonaws.com` - `X-Amz-Target`: `com.amazonaws.transcribe.Transcribe.{{StartStreamTranscription}}` - `Content-Type`: `application/vnd.amazon.eventstream` - `X-Amz-Content-Sha256`: `{{string}}` - `X-Amz-Date`: `{{20220208}}T{{235959}}Z` - `Authorization`: `AWS4-HMAC-SHA256 Credential={{access-key}}/{{20220208}}/{{us-west-2}}/transcribe/aws4_request, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target;x-amz-security-token, Signature={{string}}` - `x-amzn-transcribe-language-code`: `{{en-US}}` - `x-amzn-transcribe-media-encoding`: `{{flac}}` - `x-amzn-transcribe-sample-rate`: `{{16000}}` - `x-amzn-channel-identification`: `TRUE` - `transfer-encoding`: `chunked` ### Request Example ```http POST /stream-transcription HTTP/2 host: transcribestreaming.{{us-west-2}}.amazonaws.com X-Amz-Target: com.amazonaws.transcribe.Transcribe.{{StartStreamTranscription}} Content-Type: application/vnd.amazon.eventstream X-Amz-Content-Sha256: {{string}} X-Amz-Date: {{20220208}}T{{235959}}Z Authorization: AWS4-HMAC-SHA256 Credential={{access-key}}/{{20220208}}/{{us-west-2}}/transcribe/aws4_request, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target;x-amz-security-token, Signature={{string}} x-amzn-transcribe-language-code: {{en-US}} x-amzn-transcribe-media-encoding: {{flac}} x-amzn-transcribe-sample-rate: {{16000}} x-amzn-channel-identification: TRUE transfer-encoding: chunked ``` ### Response (Details depend on the streaming transcription response structure, which is not fully detailed here but typically includes transcription segments with channel information.) ``` -------------------------------- ### Start Medical Transcription Job Source: https://docs.aws.amazon.com/transcribe/latest/dg/example_transcribe_StartMedicalTranscriptionJob_section.md This example demonstrates how to start a medical transcription job using the `StartMedicalTranscriptionJobCommand` from the AWS SDK for JavaScript v3. It includes setting up the necessary parameters such as job name, output bucket, specialty, type, language code, media format, and media source location. ```APIDOC ## StartMedicalTranscriptionJobCommand ### Description Starts a medical transcription job to convert a medical audio file into text. ### Method `transcribeClient.send(new StartMedicalTranscriptionJobCommand(params))` ### Parameters #### Request Body - **MedicalTranscriptionJobName** (string) - Required - The name of the medical transcription job. - **OutputBucketName** (string) - Required - The name of the S3 bucket where the transcription output will be stored. - **Specialty** (string) - Required - The medical specialty for the transcription. Possible values: 'PRIMARYCARE'. - **Type** (string) - Required - The type of the transcription job. Possible values: 'CONVERSATION', 'DICTATION'. - **LanguageCode** (string) - Optional - The language code for the transcription job (e.g., 'en-US'). - **MediaFormat** (string) - Optional - The format of the input media file (e.g., 'wav'). - **Media** (object) - Required - Information about the source of the audio file. - **MediaFileUri** (string) - Required - The S3 object location of the input media file. The URI must be in the same region as the API endpoint. ### Request Example ```javascript import { StartMedicalTranscriptionJobCommand } from "@aws-sdk/client-transcribe"; import { transcribeClient } from "./libs/transcribeClient.js"; export const params = { MedicalTranscriptionJobName: "MEDICAL_JOB_NAME", OutputBucketName: "OUTPUT_BUCKET_NAME", Specialty: "PRIMARYCARE", Type: "JOB_TYPE", LanguageCode: "LANGUAGE_CODE", MediaFormat: "SOURCE_FILE_FORMAT", Media: { MediaFileUri: "SOURCE_FILE_LOCATION", }, }; export const run = async () => { try { const data = await transcribeClient.send( new StartMedicalTranscriptionJobCommand(params) ); console.log("Success - put", data); return data; } catch (err) { console.log("Error", err); } }; run(); ``` ### Response #### Success Response (200) Returns a success object upon completion of the job initiation. #### Response Example ```json { "MedicalTranscriptionJob": { "MedicalTranscriptionJobName": "MEDICAL_JOB_NAME", "TranscriptionJobStatus": "IN_PROGRESS", "FailureReason": null, "LanguageCode": "LANGUAGE_CODE", "MediaFormat": "SOURCE_FILE_FORMAT", "MediaSampleRateHertz": 0, "MediaSizeInBytes": 0, "CreationTime": "1970-01-01T00:00:00.000Z", "CompletionTime": null, "StartTime": null, "LastModifiedTime": "1970-01-01T00:00:00.000Z", "MedicalSpecialty": "PRIMARYCARE", "Type": "JOB_TYPE", "VocabularyConfig": {}, "Media": { "MediaFileUri": "SOURCE_FILE_LOCATION" }, "OutputLocationType": "CUSTOMER_AMAZON_S3", "Tags": {} } } ``` ``` -------------------------------- ### Start Call Analytics HTTP/2 Stream Request Source: https://docs.aws.amazon.com/transcribe/latest/dg/tca-start-stream.md This example shows the structure of an HTTP/2 POST request to start a Call Analytics transcription stream. It includes necessary headers like 'X-Amz-Target', 'Content-Type', and authentication details, along with the configuration payload for channel definitions and post-call analytics settings. Ensure 'PostCallAnalyticsSettings' is removed if post-call analytics are not required. ```http POST /stream-transcription HTTP/2 host: transcribestreaming.{{us-west-2}}.amazonaws.com X-Amz-Target: com.amazonaws.transcribe.Transcribe.{{StartCallAnalyticsStreamTranscription}} Content-Type: application/vnd.amazon.eventstream X-Amz-Content-Sha256: {{string}} X-Amz-Date: {{20220208}}T{{235959}}Z Authorization: AWS4-HMAC-SHA256 Credential={{access-key}}/{{20220208}}/{{us-west-2}}/transcribe/aws4_request, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target;x-amz-security-token, Signature={{string}} x-amzn-transcribe-language-code: {{en-US}} x-amzn-transcribe-media-encoding: {{flac}} x-amzn-transcribe-sample-rate: {{16000}} transfer-encoding: chunked { "AudioStream": { "AudioEvent": { "AudioChunk": blob }, "ConfigurationEvent": { "ChannelDefinitions": [ { "ChannelId": {{0}}, "ParticipantRole": "{{AGENT}}" }, { "ChannelId": {{1}}, "ParticipantRole": "{{CUSTOMER}}" } ], "PostCallAnalyticsSettings": { "OutputLocation": "s3://{{amzn-s3-demo-bucket}}/{{my-output-files}}/", "DataAccessRoleArn": "arn:aws:iam::{{111122223333}}:role/{{ExampleRole}}" } } } } ``` -------------------------------- ### Start Medical Transcription Job with Speaker Partitioning (Python SDK) Source: https://docs.aws.amazon.com/transcribe/latest/dg/conversation-diarization-batch-med.md This example demonstrates how to use the AWS SDK for Python (Boto3) to start a batch medical transcription job with speaker partitioning enabled. It includes setting job name, media file URI, output bucket, language code, specialty, transcription type, and speaker label settings. ```APIDOC ## Start Medical Transcription Job with Speaker Partitioning ### Description Starts a batch medical transcription job with speaker partitioning enabled. ### Method `start_medical_transcription_job` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **MedicalTranscriptionJobName** (string) - Required - A name that is unique in your AWS account. - **Media** (object) - Required - The media format and location. - **MediaFileUri** (string) - Required - The S3 URI of the audio file. - **OutputBucketName** (string) - Required - The Amazon S3 bucket to store the transcription results. - **OutputKey** (string) - Optional - The S3 key prefix for the transcription results. - **LanguageCode** (string) - Required - The language code for the audio file (e.g., 'en-US'). - **Specialty** (string) - Required - The medical specialty of the clinician (e.g., 'PRIMARYCARE'). - **Type** (string) - Required - The type of transcription, must be 'CONVERSATION' for speaker partitioning. - **Settings** (object) - Optional - Settings for the transcription job. - **ShowSpeakerLabels** (boolean) - Required - Set to `true` to enable speaker labels. - **MaxSpeakerLabels** (integer) - Optional - An integer between 2 and 10 to indicate the number of speakers. ### Request Example ```python 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://{{amzn-s3-demo-bucket}}/{{my-input-files}}/{{my-media-file}}.{{flac}}" transcribe.start_medical_transcription_job( MedicalTranscriptionJobName = job_name, Media={ 'MediaFileUri': job_uri }, OutputBucketName = '{{amzn-s3-demo-bucket}}', OutputKey = '{{my-output-files}}/', LanguageCode = 'en-US', Specialty = 'PRIMARYCARE', Type = 'CONVERSATION', Settings = {'ShowSpeakerLabels': True, 'MaxSpeakerLabels': 2 } ) while True: status = transcribe.get_medical_transcription_job(MedicalTranscriptionJobName = job_name) if status['MedicalTranscriptionJob']['TranscriptionJobStatus'] in ['COMPLETED', 'FAILED']: break print("Not ready yet...") time.sleep(5) print(status) ``` ### Response #### Success Response (200) Returns the status of the transcription job. #### Response Example ```json { "jobName": "job ID", "accountId": "111122223333", "results": { "transcripts": [ { "transcript": "Professional answer." } ], "speaker_labels": { "speakers": 1, "segments": [ { "start_time": "0.000000", "speaker_label": "spk_0", "end_time": "1.430", "items": [ { "start_time": "0.100", "speaker_label": "spk_0", "end_time": "0.690" }, { "start_time": "0.690", "speaker_label": "spk_0", "end_time": "1.210" } ] } ] }, "items": [ { "start_time": "0.100", "end_time": "0.690", "alternatives": [ { "confidence": "0.8162", "content": "Professional" } ], "type": "pronunciation" }, { "start_time": "0.690", "end_time": "1.210", "alternatives": [ { "confidence": "0.9939", "content": "answer" } ], "type": "pronunciation" }, { "alternatives": [ { "content": "." } ], "type": "punctuation" } ] }, "status": "COMPLETED" } ``` ```