Skip to content

Commit 99a6069

Browse files
committed
updates
1 parent a5a1152 commit 99a6069

File tree

5 files changed

+123
-85
lines changed

5 files changed

+123
-85
lines changed

components/assemblyai/actions/create-captions/create-captions.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import assemblyai from "../../assemblyai.app.mjs";
22

33
export default {
44
name: "Create Captions",
5-
description: "Export your completed transcripts in SRT (srt) or VTT (vtt) format, which can be used for subtitles and closed captions in videos. [See the documentation](https://www.assemblyai.com/docs/API%20reference/transcript)",
5+
description: "Export your completed transcripts in SRT (srt) or VTT (vtt) format, which can be used for subtitles and closed captions in videos. [See the documentation](https://www.assemblyai.com/docs/api-reference/transcripts/get-subtitles)",
66
key: "assemblyai-create-captions",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
type: "action",
99
props: {
1010
assemblyai,

components/assemblyai/actions/get-transcription/get-transcription.mjs

Lines changed: 9 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2,95 +2,26 @@ import assemblyai from "../../assemblyai.app.mjs";
22

33
export default {
44
name: "Get Transcription",
5-
description: "Fetches a specific transcribed result from the AssemblyAI API. [See the documentation](https://www.assemblyai.com/docs/API%20reference/transcript)",
5+
description: "Fetches a specific transcribed result from the AssemblyAI API. [See the documentation](https://www.assemblyai.com/docs/api-reference/transcripts/get)",
66
key: "assemblyai-get-transcription",
7-
version: "0.0.4",
7+
version: "0.0.1",
88
type: "action",
99
props: {
1010
assemblyai,
11-
url: {
12-
type: "string",
13-
label: "URL",
14-
description: "The URL of your media file to transcribe.",
15-
},
16-
languageCode: {
11+
transcriptId: {
1712
propDefinition: [
1813
assemblyai,
19-
"languageCode",
14+
"transcriptId",
2015
],
2116
},
22-
punctuate: {
23-
type: "boolean",
24-
label: "Punctuate",
25-
description: "Enable Automatic Punctuation",
26-
optional: true,
27-
},
28-
speakerLabels: {
29-
type: "boolean",
30-
label: "Speaker Labels",
31-
description: "Enable Speaker diarization",
32-
optional: true,
33-
},
34-
contentSafety: {
35-
type: "boolean",
36-
label: "Content Safety",
37-
description: "Enable Content Moderation",
38-
optional: true,
39-
},
40-
sentimentAnalysis: {
41-
type: "boolean",
42-
label: "Sentiment Analysis",
43-
description: "Enable Sentiment Analysis",
44-
optional: true,
45-
},
46-
webhookUrl: {
47-
type: "string",
48-
label: "Webhook URL",
49-
description: "The URL we should send webhooks to when your transcript is complete",
50-
optional: true,
51-
},
52-
callbackWithRerun: {
53-
type: "boolean",
54-
label: "Callback With Rerun",
55-
description: "Use the `$.flow.rerun` Node.js helper to rerun the step when the transcription is completed. Overrides the `webhookUrl` prop. This will increase execution time and credit usage as a result. [See the documentation(https://pipedream.com/docs/code/nodejs/rerun/#flow-rerun). Not available in Pipedream Connect.",
56-
optional: true,
57-
},
5817
},
5918
async run({ $ }) {
60-
let response;
61-
const context = $.context;
62-
const run = context
63-
? context.run
64-
: {
65-
runs: 1,
66-
};
67-
if (run.runs === 1) {
68-
let webhookUrl = this.webhookUrl;
69-
if (context && this.callbackWithRerun) {
70-
({ resume_url: webhookUrl } = $.flow.rerun(600000, null, 1));
71-
}
72-
response = await this.assemblyai.createTranscript({
73-
data: {
74-
audio_url: this.url,
75-
language_code: this.languageCode,
76-
punctuate: this.punctuate,
77-
speaker_labels: this.speakerLabels,
78-
content_safety: this.contentSafety,
79-
sentiment_analysis: this.sentimentAnalysis,
80-
webhook_url: webhookUrl,
81-
},
82-
$,
83-
});
84-
}
85-
if (run.callback_request) {
86-
response = await this.assemblyai.getTranscript({
87-
transcriptId: run.callback_request.body.transcript_id,
88-
});
89-
}
19+
const response = await this.assemblyai.getTranscript({
20+
transcriptId: this.transcriptId,
21+
$,
22+
});
9023

91-
if (response?.id) {
92-
$.export("$summary", `Successfully created transcription with ID ${response.id}.`);
93-
}
24+
$.export("$summary", `Successfully retrieved transcription for transcript with ID ${this.transcriptId}.`);
9425

9526
return response;
9627
},
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import assemblyai from "../../assemblyai.app.mjs";
2+
3+
export default {
4+
name: "Transcribe Audio",
5+
description: "Create a transcript from a media file that is accessible via a URL. [See the documentation](https://www.assemblyai.com/docs/api-reference/transcripts/submit)",
6+
key: "assemblyai-transcribe-audio",
7+
version: "0.1.0",
8+
type: "action",
9+
props: {
10+
assemblyai,
11+
url: {
12+
type: "string",
13+
label: "URL",
14+
description: "The URL of your media file to transcribe.",
15+
},
16+
languageCode: {
17+
propDefinition: [
18+
assemblyai,
19+
"languageCode",
20+
],
21+
},
22+
punctuate: {
23+
type: "boolean",
24+
label: "Punctuate",
25+
description: "Enable Automatic Punctuation",
26+
optional: true,
27+
},
28+
speakerLabels: {
29+
type: "boolean",
30+
label: "Speaker Labels",
31+
description: "Enable Speaker diarization",
32+
optional: true,
33+
},
34+
contentSafety: {
35+
type: "boolean",
36+
label: "Content Safety",
37+
description: "Enable Content Moderation",
38+
optional: true,
39+
},
40+
sentimentAnalysis: {
41+
type: "boolean",
42+
label: "Sentiment Analysis",
43+
description: "Enable Sentiment Analysis",
44+
optional: true,
45+
},
46+
webhookUrl: {
47+
type: "string",
48+
label: "Webhook URL",
49+
description: "The URL we should send webhooks to when your transcript is complete",
50+
optional: true,
51+
},
52+
callbackWithRerun: {
53+
type: "boolean",
54+
label: "Callback With Rerun",
55+
description: "Use the `$.flow.rerun` Node.js helper to rerun the step when the transcription is completed. Overrides the `webhookUrl` prop. This will increase execution time and credit usage as a result. [See the documentation(https://pipedream.com/docs/code/nodejs/rerun/#flow-rerun). Not available in Pipedream Connect.",
56+
optional: true,
57+
},
58+
},
59+
async run({ $ }) {
60+
let response;
61+
const context = $.context;
62+
const run = context
63+
? context.run
64+
: {
65+
runs: 1,
66+
};
67+
if (run.runs === 1) {
68+
let webhookUrl = this.webhookUrl;
69+
if (context && this.callbackWithRerun) {
70+
({ resume_url: webhookUrl } = $.flow.rerun(600000, null, 1));
71+
}
72+
response = await this.assemblyai.createTranscript({
73+
data: {
74+
audio_url: this.url,
75+
language_code: this.languageCode,
76+
punctuate: this.punctuate,
77+
speaker_labels: this.speakerLabels,
78+
content_safety: this.contentSafety,
79+
sentiment_analysis: this.sentimentAnalysis,
80+
webhook_url: webhookUrl,
81+
},
82+
$,
83+
});
84+
}
85+
if (run.callback_request) {
86+
response = await this.assemblyai.getTranscript({
87+
transcriptId: run.callback_request.body.transcript_id,
88+
});
89+
}
90+
91+
if (response?.id) {
92+
$.export("$summary", `Successfully created transcription with ID ${response.id}.`);
93+
}
94+
95+
return response;
96+
},
97+
};

components/assemblyai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/assemblyai",
3-
"version": "0.2.2",
3+
"version": "0.3.0",
44
"description": "Pipedream AssemblyAI Components",
55
"main": "assemblyai.app.mjs",
66
"keywords": [

components/assemblyai/sources/new-transcription-completed/new-transcription-completed.mjs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
33

44
export default {
55
name: "New Transcription Completed",
6-
description: "Emit new event when a transcribed audio file from AssemblyAI is ready. [See the documentation](https://www.assemblyai.com/docs/API%20reference/transcript)",
6+
description: "Emit new event when a transcribed audio file from AssemblyAI is ready. [See the documentation](https://www.assemblyai.com/docs/api-reference/transcripts/list)",
77
key: "assemblyai-new-transcription-completed",
8-
version: "0.0.2",
8+
version: "0.1.0",
99
type: "source",
1010
dedupe: "unique",
1111
props: {
@@ -30,7 +30,7 @@ export default {
3030
return;
3131
}
3232
this._setLastId(transcripts[0].id);
33-
transcripts.reverse().forEach((transcript) => this.emitEvent(transcript));
33+
await this.emitTranscripts(transcripts);
3434
},
3535
},
3636
methods: {
@@ -44,6 +44,14 @@ export default {
4444
const meta = this.generateMeta(transcript);
4545
this.$emit(transcript, meta);
4646
},
47+
async emitTranscripts(transcripts) {
48+
for (const transcript of transcripts.reverse()) {
49+
const data = await this.assemblyai.getTranscript({
50+
transcriptId: transcript.id,
51+
});
52+
this.emitEvent(data);
53+
}
54+
},
4755
generateMeta(transcript) {
4856
return {
4957
id: transcript.id,
@@ -63,7 +71,9 @@ export default {
6371
if (!transcripts.length) {
6472
return;
6573
}
66-
transcripts.forEach((transcript) => this.emitEvent(transcript));
74+
6775
this._setLastId(transcripts[0].id);
76+
77+
await this.emitTranscripts(transcripts);
6878
},
6979
};

0 commit comments

Comments
 (0)