Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import assemblyai from "../../assemblyai.app.mjs";

export default {
name: "Create Captions",
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)",
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)",
key: "assemblyai-create-captions",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
assemblyai,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,95 +2,26 @@ import assemblyai from "../../assemblyai.app.mjs";

export default {
name: "Get Transcription",
description: "Fetches a specific transcribed result from the AssemblyAI API. [See the documentation](https://www.assemblyai.com/docs/API%20reference/transcript)",
description: "Fetches a specific transcribed result from the AssemblyAI API. [See the documentation](https://www.assemblyai.com/docs/api-reference/transcripts/get)",
key: "assemblyai-get-transcription",
version: "0.0.4",
version: "0.1.0",
type: "action",
props: {
assemblyai,
url: {
type: "string",
label: "URL",
description: "The URL of your media file to transcribe.",
},
languageCode: {
transcriptId: {
propDefinition: [
assemblyai,
"languageCode",
"transcriptId",
],
},
punctuate: {
type: "boolean",
label: "Punctuate",
description: "Enable Automatic Punctuation",
optional: true,
},
speakerLabels: {
type: "boolean",
label: "Speaker Labels",
description: "Enable Speaker diarization",
optional: true,
},
contentSafety: {
type: "boolean",
label: "Content Safety",
description: "Enable Content Moderation",
optional: true,
},
sentimentAnalysis: {
type: "boolean",
label: "Sentiment Analysis",
description: "Enable Sentiment Analysis",
optional: true,
},
webhookUrl: {
type: "string",
label: "Webhook URL",
description: "The URL we should send webhooks to when your transcript is complete",
optional: true,
},
callbackWithRerun: {
type: "boolean",
label: "Callback With Rerun",
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.",
optional: true,
},
},
async run({ $ }) {
let response;
const context = $.context;
const run = context
? context.run
: {
runs: 1,
};
if (run.runs === 1) {
let webhookUrl = this.webhookUrl;
if (context && this.callbackWithRerun) {
({ resume_url: webhookUrl } = $.flow.rerun(600000, null, 1));
}
response = await this.assemblyai.createTranscript({
data: {
audio_url: this.url,
language_code: this.languageCode,
punctuate: this.punctuate,
speaker_labels: this.speakerLabels,
content_safety: this.contentSafety,
sentiment_analysis: this.sentimentAnalysis,
webhook_url: webhookUrl,
},
$,
});
}
if (run.callback_request) {
response = await this.assemblyai.getTranscript({
transcriptId: run.callback_request.body.transcript_id,
});
}
const response = await this.assemblyai.getTranscript({
transcriptId: this.transcriptId,
$,
});

if (response?.id) {
$.export("$summary", `Successfully created transcription with ID ${response.id}.`);
}
$.export("$summary", `Successfully retrieved transcription for transcript with ID ${this.transcriptId}.`);

return response;
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import assemblyai from "../../assemblyai.app.mjs";

export default {
name: "Transcribe Audio",
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)",
key: "assemblyai-transcribe-audio",
version: "0.1.0",
type: "action",
props: {
assemblyai,
url: {
type: "string",
label: "URL",
description: "The URL of your media file to transcribe.",
},
languageCode: {
propDefinition: [
assemblyai,
"languageCode",
],
},
punctuate: {
type: "boolean",
label: "Punctuate",
description: "Enable Automatic Punctuation",
optional: true,
},
speakerLabels: {
type: "boolean",
label: "Speaker Labels",
description: "Enable Speaker diarization",
optional: true,
},
contentSafety: {
type: "boolean",
label: "Content Safety",
description: "Enable Content Moderation",
optional: true,
},
sentimentAnalysis: {
type: "boolean",
label: "Sentiment Analysis",
description: "Enable Sentiment Analysis",
optional: true,
},
webhookUrl: {
type: "string",
label: "Webhook URL",
description: "The URL we should send webhooks to when your transcript is complete",
optional: true,
},
callbackWithRerun: {
type: "boolean",
label: "Callback With Rerun",
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.",
optional: true,
},
},
async run({ $ }) {
let response;
const context = $.context;
const run = context
? context.run
: {
runs: 1,
};
if (run.runs === 1) {
let webhookUrl = this.webhookUrl;
if (context && this.callbackWithRerun) {
({ resume_url: webhookUrl } = $.flow.rerun(600000, null, 1));
}
response = await this.assemblyai.createTranscript({
data: {
audio_url: this.url,
language_code: this.languageCode,
punctuate: this.punctuate,
speaker_labels: this.speakerLabels,
content_safety: this.contentSafety,
sentiment_analysis: this.sentimentAnalysis,
webhook_url: webhookUrl,
},
$,
});
}
if (run.callback_request) {
response = await this.assemblyai.getTranscript({
transcriptId: run.callback_request.body.transcript_id,
});
}

if (response?.id) {
$.export("$summary", `Successfully created transcription with ID ${response.id}.`);
}

return response;
},
};
2 changes: 1 addition & 1 deletion components/assemblyai/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/assemblyai",
"version": "0.2.2",
"version": "0.3.0",
"description": "Pipedream AssemblyAI Components",
"main": "assemblyai.app.mjs",
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";

export default {
name: "New Transcription Completed",
description: "Emit new event when a transcribed audio file from AssemblyAI is ready. [See the documentation](https://www.assemblyai.com/docs/API%20reference/transcript)",
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)",
key: "assemblyai-new-transcription-completed",
version: "0.0.2",
version: "0.1.0",
type: "source",
dedupe: "unique",
props: {
Expand All @@ -30,7 +30,7 @@ export default {
return;
}
this._setLastId(transcripts[0].id);
transcripts.reverse().forEach((transcript) => this.emitEvent(transcript));
await this.emitTranscripts(transcripts);
},
},
methods: {
Expand All @@ -44,6 +44,14 @@ export default {
const meta = this.generateMeta(transcript);
this.$emit(transcript, meta);
},
async emitTranscripts(transcripts) {
for (const transcript of transcripts.reverse()) {
const data = await this.assemblyai.getTranscript({
transcriptId: transcript.id,
});
this.emitEvent(data);
}
},
generateMeta(transcript) {
return {
id: transcript.id,
Expand All @@ -63,7 +71,9 @@ export default {
if (!transcripts.length) {
return;
}
transcripts.forEach((transcript) => this.emitEvent(transcript));

this._setLastId(transcripts[0].id);

await this.emitTranscripts(transcripts);
},
};
15 changes: 5 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading