SDK for JavaScript (v3) を使用した Amazon Transcribe の例 - AWS SDK コードサンプル

Doc AWS SDK Examples リポジトリには、他にも SDK の例があります。 AWS GitHub

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

SDK for JavaScript (v3) を使用した Amazon Transcribe の例

次のコード例は、Amazon Transcribe で AWS SDK for JavaScript (v3) を使用してアクションを実行し、一般的なシナリオを実装する方法を示しています。

アクションはより大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。アクションは個々のサービス機能を呼び出す方法を示していますが、関連するシナリオやサービス間の例ではアクションのコンテキストが確認できます。

「シナリオ」は、同じサービス内で複数の関数を呼び出して、特定のタスクを実行する方法を示すコード例です。

各例には、 へのリンクが含まれています。このリンクには GitHub、コンテキスト内でコードをセットアップして実行する方法の手順が記載されています。

トピック

アクション

次のコード例は、Amazon Transcribe Medical 文字起こしジョブを削除する方法を示しています。

SDK for JavaScript (v3)
注記

には他にもがあります GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

クライアントを作成します。

const { TranscribeClient } = require("@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 { 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();

次のコード例は、Amazon Transcribe 文字起こしジョブを削除する方法を示しています。

SDK for JavaScript (v3)
注記

には他にもがあります GitHub。用例一覧を検索し、AWS コードサンプルリポジトリでの設定と実行の方法を確認してください。

文字起こしジョブを削除します。

// 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();

クライアントを作成します。

const { TranscribeClient } = require("@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 };

次のコード例は、Amazon Transcribe Medical 文字起こしジョブを一覧表示する方法を示しています。

SDK for JavaScript (v3)
注記

には他にもがあります GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

クライアントを作成します。

const { TranscribeClient } = require("@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();

次のコード例は、Amazon Transcribe 文字起こしジョブを一覧表示する方法を示しています。

SDK for JavaScript (v3)
注記

には他にもがあります GitHub。用例一覧を検索し、AWS コードサンプルリポジトリでの設定と実行の方法を確認してください。

文字起こしジョブを一覧表示します。

// 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();

クライアントを作成します。

const { TranscribeClient } = require("@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 };

次のコード例は、Amazon Transcribe Medical 文字起こしジョブを開始する方法を示しています。

SDK for JavaScript (v3)
注記

には他にもがあります GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

クライアントを作成します。

const { TranscribeClient } = require("@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();

次のコード例は、Amazon Transcribe 文字起こしジョブを開始する方法を示しています。

SDK for JavaScript (v3)
注記

には他にもがあります GitHub。用例一覧を検索し、AWS コードサンプルリポジトリでの設定と実行の方法を確認してください。

文字起こしジョブを開始します。

// 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();

クライアントを作成します。

const { TranscribeClient } = require("@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 };