Amazon Transcribe examples using SDK for JavaScript (v3) (original) (raw)
The following code examples show you how to perform actions and implement common scenarios by using the AWS SDK for JavaScript (v3) with Amazon Transcribe.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Scenarios are code examples that show you how to accomplish specific tasks by calling multiple functions within a service or combined with other AWS services.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Actions
The following code example shows how to use DeleteMedicalTranscriptionJob
.
SDK for JavaScript (v3)
Create the client.
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 };
Delete a medical transcription job.
// Import the required AWS SDK clients and commands for Node.js
import { DeleteMedicalTranscriptionJobCommand } from "@aws-sdk/client-transcribe";
import { transcribeClient } from "./libs/transcribeClient.js";
// Set the parameters
export const params = {
MedicalTranscriptionJobName: "MEDICAL_JOB_NAME", // For example, 'medical_transciption_demo'
};
export const run = async () => {
try {
const data = await transcribeClient.send(
new DeleteMedicalTranscriptionJobCommand(params),
);
console.log("Success - deleted");
return data; // For unit tests.
} catch (err) {
console.log("Error", err);
}
};
run();
- For more information, see AWS SDK for JavaScript Developer Guide.
- For API details, seeDeleteMedicalTranscriptionJob in AWS SDK for JavaScript API Reference.
The following code example shows how to use DeleteTranscriptionJob
.
SDK for JavaScript (v3)
Delete a transcription job.
// Import the required AWS SDK clients and commands for Node.js
import { DeleteTranscriptionJobCommand } from "@aws-sdk/client-transcribe";
import { transcribeClient } from "./libs/transcribeClient.js";
// Set the parameters
export const params = {
TranscriptionJobName: "JOB_NAME", // Required. For example, 'transciption_demo'
};
export const run = async () => {
try {
const data = await transcribeClient.send(
new DeleteTranscriptionJobCommand(params),
);
console.log("Success - deleted");
return data; // For unit tests.
} catch (err) {
console.log("Error", err);
}
};
run();
Create the client.
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 };
- For more information, see AWS SDK for JavaScript Developer Guide.
- For API details, seeDeleteTranscriptionJob in AWS SDK for JavaScript API Reference.
The following code example shows how to use ListMedicalTranscriptionJobs
.
SDK for JavaScript (v3)
Create the client.
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 };
List medical transcription jobs.
// 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();
- For more information, see AWS SDK for JavaScript Developer Guide.
- For API details, seeListMedicalTranscriptionJobs in AWS SDK for JavaScript API Reference.
The following code example shows how to use ListTranscriptionJobs
.
SDK for JavaScript (v3)
List transcription jobs.
// Import the required AWS SDK clients and commands for Node.js
import { ListTranscriptionJobsCommand } from "@aws-sdk/client-transcribe";
import { transcribeClient } from "./libs/transcribeClient.js";
// Set the parameters
export const params = {
JobNameContains: "KEYWORD", // Not required. Returns only transcription
// job names containing this string
};
export const run = async () => {
try {
const data = await transcribeClient.send(
new ListTranscriptionJobsCommand(params),
);
console.log("Success", data.TranscriptionJobSummaries);
return data; // For unit tests.
} catch (err) {
console.log("Error", err);
}
};
run();
Create the client.
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 };
- For more information, see AWS SDK for JavaScript Developer Guide.
- For API details, seeListTranscriptionJobs in AWS SDK for JavaScript API Reference.
The following code example shows how to use StartMedicalTranscriptionJob
.
SDK for JavaScript (v3)
Create the client.
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 };
Start a medical transcription job.
// 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();
- For more information, see AWS SDK for JavaScript Developer Guide.
- For API details, seeStartMedicalTranscriptionJob in AWS SDK for JavaScript API Reference.
The following code example shows how to use StartTranscriptionJob
.
SDK for JavaScript (v3)
Start a transcription job.
// 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();
Create the client.
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 };
- For more information, see AWS SDK for JavaScript Developer Guide.
- For API details, seeStartTranscriptionJob in AWS SDK for JavaScript API Reference.
Scenarios
The following code example shows how to build an app that records, transcribes, and translates live audio in real-time, and emails the results.
SDK for JavaScript (v3)
Shows how to use Amazon Transcribe to build an app that records, transcribes, and translates live audio in real-time, and emails the results using Amazon Simple Email Service (Amazon SES).
For complete source code and instructions on how to set up and run, see the full example onGitHub.
Services used in this example
- Amazon Comprehend
- Amazon SES
- Amazon Transcribe
- Amazon Translate
Amazon Textract
Amazon Translate
Did this page help you? - Yes
Thanks for letting us know we're doing a good job!
If you've got a moment, please tell us what we did right so we can do more of it.
Did this page help you? - No
Thanks for letting us know this page needs work. We're sorry we let you down.
If you've got a moment, please tell us how we can make the documentation better.