-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
71 lines (67 loc) · 1.7 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { Configuration as OpenAIConfiguration, OpenAIApi } from "openai";
import config from "./config.json" assert { type: "json" };
import { createReadStream } from "fs";
import { readdir } from "fs/promises";
import _ from "lodash";
export const openaiConfiguration = new OpenAIConfiguration({
apiKey: config.openAI,
});
export const openai = new OpenAIApi(openaiConfiguration);
console.log(
(
await Promise.allSettled(
_.take(
await readdir("./recordings/5f9c6c17-5fbb-4a6b-95b9-f776a163f51c"),
1000
).map((v) =>
openai.createTranscription(
createReadStream(
"./recordings/5f9c6c17-5fbb-4a6b-95b9-f776a163f51c/" + v
),
"whisper-1",
undefined,
"verbose_json",
undefined,
"en"
)
)
)
).map((r) => r.value?.data?.text)
);
// try {
// console.log(
// (
// await Promise.all([
// _.first(
// await readdir("./recordings/5f9c6c17-5fbb-4a6b-95b9-f776a163f51c"),
// 2
// ).map((p) =>
// openai.createTranscription(
// createReadStream(p),
// "whisper-1",
// undefined,
// "verbose_json",
// undefined,
// "en"
// )
// ),
// ])
// ).length
// );
// } catch (error) {
// console.log(error);
// }
// console.log(
// (
// await openai.createTranscription(
// await createReadStream(
// "./recordings/5f9c6c17-5fbb-4a6b-95b9-f776a163f51c/1679702232649-744368561132273675.wav"
// ),
// "whisper-1",
// undefined,
// "verbose_json",
// undefined,
// "en"
// )
// ).data
// );