Skip to content

Commit 99af0d8

Browse files
committed
test(client-transcribe-streaming): re-enable e2e
1 parent 4173472 commit 99af0d8

File tree

1 file changed

+42
-41
lines changed

1 file changed

+42
-41
lines changed
Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,48 @@
1-
import { createReadStream } from "fs";
2-
import { join } from "path";
1+
import { TranscribeStreaming } from "@aws-sdk/client-transcribe-streaming";
2+
import { createReadStream } from "node:fs";
3+
import { join } from "node:path";
34
import { afterAll, beforeAll, describe, expect, test as it } from "vitest";
45

5-
import { TranscribeStreaming } from "../src/index";
66
const audio = createReadStream(join(__dirname, "numbers.wav"));
77

8-
describe("TranscribeStream client", () => {
9-
const client = new TranscribeStreaming({
10-
region: "us-west-2",
11-
credentials: {
12-
accessKeyId: "CLIENT_TEST",
13-
secretAccessKey: "CLIENT_TEST",
14-
},
15-
});
16-
17-
beforeAll(async () => {});
18-
afterAll(() => {
19-
client.destroy();
20-
});
8+
describe(
9+
"TranscribeStream client",
10+
() => {
11+
const client = new TranscribeStreaming({
12+
region: "us-west-2",
13+
});
2114

22-
// TODO: not working in Node.js with HTTP2 handler?
23-
it.skip("should stream the transcript", async () => {
24-
const LanguageCode = "en-GB";
25-
const MediaEncoding = "pcm";
26-
const MediaSampleRateHertz = 44100;
27-
const result = await client.startStreamTranscription({
28-
LanguageCode,
29-
MediaEncoding,
30-
MediaSampleRateHertz,
31-
AudioStream: (async function* () {
32-
for await (const chunk of audio) {
33-
yield { AudioEvent: { AudioChunk: chunk } };
34-
}
35-
})(),
15+
beforeAll(async () => {});
16+
afterAll(() => {
17+
client.destroy();
3618
});
37-
expect(result.LanguageCode).toBe(LanguageCode);
38-
expect(result.MediaEncoding).toBe(MediaEncoding);
39-
expect(result.MediaSampleRateHertz).toBe(MediaSampleRateHertz);
40-
expect(result.TranscriptResultStream).toBeDefined();
41-
const transcripts: any[] = [];
42-
for await (const event of result.TranscriptResultStream!) {
43-
transcripts.push(event);
44-
}
45-
expect(transcripts.filter((event) => event["TranscriptEvent"]).length).toBeGreaterThan(0);
46-
}, 60000);
47-
});
19+
20+
it("should stream the transcript", async () => {
21+
const LanguageCode = "en-GB";
22+
const MediaEncoding = "pcm";
23+
const MediaSampleRateHertz = 44100;
24+
const result = await client.startStreamTranscription({
25+
LanguageCode,
26+
MediaEncoding,
27+
MediaSampleRateHertz,
28+
AudioStream: (async function* () {
29+
for await (const chunk of audio) {
30+
yield { AudioEvent: { AudioChunk: chunk } };
31+
}
32+
})(),
33+
});
34+
expect(result.LanguageCode).toBe(LanguageCode);
35+
expect(result.MediaEncoding).toBe(MediaEncoding);
36+
expect(result.MediaSampleRateHertz).toBe(MediaSampleRateHertz);
37+
expect(result.TranscriptResultStream).toBeDefined();
38+
const transcripts: any[] = [];
39+
for await (const event of result.TranscriptResultStream!) {
40+
transcripts.push(event);
41+
}
42+
expect(transcripts.filter((event) => event["TranscriptEvent"]).length).toBeGreaterThan(0);
43+
}, 60000);
44+
},
45+
{
46+
retry: 4,
47+
}
48+
);

0 commit comments

Comments
 (0)