Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/transcriber-amazon-transcribe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"/dist"
],
"dependencies": {
"aws-transcribe": "1.1.0",
"@aws-sdk/client-transcribe": "^3.15.0",
"debug": "^4.3.1",
"wavefile": "^11.0.0"
},
Expand Down
17 changes: 17 additions & 0 deletions packages/transcriber-amazon-transcribe/src/AmazonTranscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ import {
} from "aws-transcribe/dist/types";
import { Debugger } from "./Debugger";

import {
TranscribeClient,
CreateLanguageModelCommand,
StartTranscriptionJobCommand,
} from "@aws-sdk/client-transcribe";

// Not sure which version
// https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/transcribe-examples-section.html
// https://www.npmjs.com/package/@aws-sdk/client-transcribe-streaming

export class AmazonTranscribe
extends TypedEmitter<TranscriptionEvents>
implements TranscriberPlugin {
Expand All @@ -22,11 +32,18 @@ export class AmazonTranscribe

private stream: StreamingClient;

private transcribeClient: TranscribeClient;

constructor(
private readonly region: AVAILABLE_REGIONS,
private readonly languageCode: LANGUAGES
) {
super();
this.transcribeClient = new TranscribeClient({ region: this.region });
const command = new StartTranscriptionJobCommand(input);
const response = await client.send(command);

this.transcribeClient.send();
this.config = {
region: this.region,
sampleRate: 8000,
Expand Down
16 changes: 2 additions & 14 deletions packages/transcriber-amazon-transcribe/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AVAILABLE_REGIONS, LANGUAGES } from "aws-transcribe/dist/types";
import { TranscriberFactory } from "ivr-tester";
import { AmazonTranscribe } from "./AmazonTranscribe";

Expand All @@ -10,12 +9,12 @@ export interface AmazonTranscribeOptions {
/**
* AWS region of the Amazon Transcribe resource
*/
region: AVAILABLE_REGIONS;
region: string;

/**
* Language of the supplied audio as a BCP-47 language tag.
*/
languageCode?: LANGUAGES;
languageCode?: string;
}

/**
Expand All @@ -28,17 +27,6 @@ export const amazonTranscribe = ({
}: AmazonTranscribeOptions): TranscriberFactory => ({
create: () => new AmazonTranscribe(region, languageCode),
checkCanRun: () => {
const credentialsDefined =
process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY;

if (!credentialsDefined) {
return {
canRun: false,
reason: `Cannot find Amazon Transcribe credentials. Please ensure you define the environment variables:
AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY`,
};
}

return { canRun: true };
},
});
Loading