Skip to content

Commit eaddfd0

Browse files
committed
test(client-transcribe-streaming): add smoke test
1 parent 7f86b04 commit eaddfd0

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/coverage/
22
/docs/
3+
/test/
34
tsconfig.test.json
45
*.tsbuildinfo

clients/client-transcribe-streaming/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
"remove-documentation": "rimraf ./docs",
1313
"remove-js": "rimraf *.js && rimraf ./commands/*.js && rimraf ./models/*.js && rimraf ./protocols/*.js",
1414
"remove-maps": "rimraf *.js.map && rimraf ./commands/*.js.map && rimraf ./models/*.js.map && rimraf ./protocols/*.js.map",
15-
"test": "exit 0",
16-
"smoke-test": "npm run pretest && node ./test/smoke/index.spec.js",
15+
"test:integ": "npm run pretest && jest ./test/integ/index.nodejs.spec.js",
1716
"build:es": "tsc -p tsconfig.es.json",
1817
"build": "yarn pretest && yarn build:es"
1918
},
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { TranscribeStreaming, TranscriptResultStream } from "../../index";
2+
import { createReadStream } from "fs";
3+
import { join } from "path";
4+
const moduleRoot = join(__dirname, "..", "..", "..", "..");
5+
const audio = createReadStream(join(moduleRoot, "test", "integ", "speech.wav"));
6+
7+
describe("TranscribeStream client", () => {
8+
const client = new TranscribeStreaming({});
9+
afterAll(() => {
10+
client.destroy();
11+
});
12+
13+
it("should stream the transcript", async () => {
14+
const result = await client.startStreamTranscription({
15+
LanguageCode: "en-US",
16+
MediaEncoding: "pcm",
17+
MediaSampleRateHertz: 44100,
18+
AudioStream: (async function* () {
19+
for await (const chunk of audio) {
20+
yield { AudioEvent: { AudioChunk: chunk } };
21+
}
22+
})()
23+
});
24+
expect(result.LanguageCode).toBe("en-US");
25+
expect(result.MediaEncoding).toBe("pcm");
26+
expect(result.MediaSampleRateHertz).toBe(44100);
27+
expect(result.TranscriptResultStream).toBeDefined();
28+
const transcripts = [];
29+
for await (const event of result.TranscriptResultStream!) {
30+
transcripts.push(event);
31+
}
32+
expect(
33+
transcripts.filter(event => event["TranscriptEvent"]).length
34+
).toBeGreaterThan(0);
35+
}, 60000);
36+
});
Binary file not shown.

0 commit comments

Comments
 (0)