@pipedream/openai 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/actions/common/lang.mjs
CHANGED
|
@@ -32,6 +32,70 @@ export default {
|
|
|
32
32
|
"label": "Arabic",
|
|
33
33
|
"value": "ar",
|
|
34
34
|
},
|
|
35
|
+
{
|
|
36
|
+
"label": "Arabic (Algeria)",
|
|
37
|
+
"value": "ar-dz"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"label": "Arabic (Bahrain)",
|
|
41
|
+
"value": "ar-bh"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"label": "Arabic (Egypt)",
|
|
45
|
+
"value": "ar-eg"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"label": "Arabic (Iraq)",
|
|
49
|
+
"value": "ar-iq"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"label": "Arabic (Jordan)",
|
|
53
|
+
"value": "ar-jo"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"label": "Arabic (Kuwait)",
|
|
57
|
+
"value": "ar-kw"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"label": "Arabic (Lebanon)",
|
|
61
|
+
"value": "ar-lb"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"label": "Arabic (Libya)",
|
|
65
|
+
"value": "ar-ly"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"label": "Arabic (Morocco)",
|
|
69
|
+
"value": "ar-ma"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"label": "Arabic (Oman)",
|
|
73
|
+
"value": "ar-om"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"label": "Arabic (Qatar)",
|
|
77
|
+
"value": "ar-qa"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"label": "Arabic (Saudi Arabia)",
|
|
81
|
+
"value": "ar-sa"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"label": "Arabic (Syria)",
|
|
85
|
+
"value": "ar-sy"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"label": "Arabic (Tunisia)",
|
|
89
|
+
"value": "ar-tn"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"label": "Arabic (U.A.E.)",
|
|
93
|
+
"value": "ar-ae"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"label": "Arabic (Yemen)",
|
|
97
|
+
"value": "ar-ye"
|
|
98
|
+
},
|
|
35
99
|
{
|
|
36
100
|
"label": "Assamese",
|
|
37
101
|
"value": "as",
|
|
@@ -22,7 +22,7 @@ const pipelineAsync = promisify(stream.pipeline);
|
|
|
22
22
|
|
|
23
23
|
export default {
|
|
24
24
|
name: "Create Transcription",
|
|
25
|
-
version: "0.0.
|
|
25
|
+
version: "0.0.8",
|
|
26
26
|
key: "openai-create-transcription",
|
|
27
27
|
description: "Transcribes audio into the input language. [See docs here](https://platform.openai.com/docs/api-reference/audio/create).",
|
|
28
28
|
type: "action",
|
|
@@ -117,15 +117,12 @@ export default {
|
|
|
117
117
|
});
|
|
118
118
|
|
|
119
119
|
const files = await fs.promises.readdir(outputDir);
|
|
120
|
-
|
|
120
|
+
|
|
121
|
+
return await this.transcribeFiles({
|
|
121
122
|
files,
|
|
122
123
|
outputDir,
|
|
123
124
|
$,
|
|
124
125
|
});
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
transcription,
|
|
128
|
-
};
|
|
129
126
|
},
|
|
130
127
|
async chunkFile({
|
|
131
128
|
file, outputDir,
|
|
@@ -155,7 +152,7 @@ export default {
|
|
|
155
152
|
const command = `${ffmpegPath} -i "${file}" -f segment -segment_time ${segmentTime} -c copy "${outputDir}/chunk-%03d${ext}"`;
|
|
156
153
|
await execAsync(command);
|
|
157
154
|
},
|
|
158
|
-
|
|
155
|
+
transcribeFiles({
|
|
159
156
|
files, outputDir, $,
|
|
160
157
|
}) {
|
|
161
158
|
const limiter = new Bottleneck({
|
|
@@ -163,27 +160,28 @@ export default {
|
|
|
163
160
|
minTime: 1000 / 59,
|
|
164
161
|
});
|
|
165
162
|
|
|
166
|
-
|
|
163
|
+
return Promise.all(files.map((file) => {
|
|
167
164
|
return limiter.schedule(() => this.transcribe({
|
|
168
165
|
file,
|
|
169
166
|
outputDir,
|
|
170
167
|
$,
|
|
171
168
|
}));
|
|
172
169
|
}));
|
|
173
|
-
return transcriptions.join(" ");
|
|
174
170
|
},
|
|
175
|
-
|
|
171
|
+
transcribe({
|
|
176
172
|
file, outputDir, $,
|
|
177
173
|
}) {
|
|
178
174
|
const form = this.createForm({
|
|
179
175
|
file,
|
|
180
176
|
outputDir,
|
|
181
177
|
});
|
|
182
|
-
|
|
178
|
+
return this.openai.createTranscription({
|
|
183
179
|
$,
|
|
184
180
|
form,
|
|
185
181
|
});
|
|
186
|
-
|
|
182
|
+
},
|
|
183
|
+
getFullText(transcriptions = []) {
|
|
184
|
+
return transcriptions.map((t) => t.text || t).join(" ");
|
|
187
185
|
},
|
|
188
186
|
},
|
|
189
187
|
async run({ $ }) {
|
|
@@ -225,15 +223,18 @@ export default {
|
|
|
225
223
|
file = downloadPath;
|
|
226
224
|
}
|
|
227
225
|
|
|
228
|
-
const
|
|
226
|
+
const transcriptions = await this.chunkFileAndTranscribe({
|
|
229
227
|
file,
|
|
230
228
|
$,
|
|
231
229
|
});
|
|
232
230
|
|
|
233
|
-
if (
|
|
231
|
+
if (transcriptions.length) {
|
|
234
232
|
$.export("$summary", "Successfully created transcription");
|
|
235
233
|
}
|
|
236
234
|
|
|
237
|
-
return
|
|
235
|
+
return {
|
|
236
|
+
transcription: this.getFullText(transcriptions),
|
|
237
|
+
transcriptions,
|
|
238
|
+
};
|
|
238
239
|
},
|
|
239
240
|
};
|
|
@@ -9,7 +9,7 @@ const langOptions = lang.LANGUAGES.map((l) => ({
|
|
|
9
9
|
export default {
|
|
10
10
|
...common,
|
|
11
11
|
name: "Translate Text",
|
|
12
|
-
version: "0.0.
|
|
12
|
+
version: "0.0.5",
|
|
13
13
|
key: "openai-translate-text",
|
|
14
14
|
description: "Translate text from one language to another using the Chat API",
|
|
15
15
|
type: "action",
|