diff --git a/components/assemblyai/actions/create-captions/create-captions.mjs b/components/assemblyai/actions/create-captions/create-captions.mjs index 8fb97f6f89717..4a80f50f5104e 100644 --- a/components/assemblyai/actions/create-captions/create-captions.mjs +++ b/components/assemblyai/actions/create-captions/create-captions.mjs @@ -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, diff --git a/components/assemblyai/actions/get-transcription/get-transcription.mjs b/components/assemblyai/actions/get-transcription/get-transcription.mjs index 0be26b1b831a9..8c7ebfbf435fa 100644 --- a/components/assemblyai/actions/get-transcription/get-transcription.mjs +++ b/components/assemblyai/actions/get-transcription/get-transcription.mjs @@ -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; }, diff --git a/components/assemblyai/actions/transcribe-audio/transcribe-audio.mjs b/components/assemblyai/actions/transcribe-audio/transcribe-audio.mjs new file mode 100644 index 0000000000000..1dd5c065aafa9 --- /dev/null +++ b/components/assemblyai/actions/transcribe-audio/transcribe-audio.mjs @@ -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; + }, +}; diff --git a/components/assemblyai/package.json b/components/assemblyai/package.json index 512ce1a4a6e5d..3a56d27799cf4 100644 --- a/components/assemblyai/package.json +++ b/components/assemblyai/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/assemblyai", - "version": "0.2.2", + "version": "0.3.0", "description": "Pipedream AssemblyAI Components", "main": "assemblyai.app.mjs", "keywords": [ diff --git a/components/assemblyai/sources/new-transcription-completed/new-transcription-completed.mjs b/components/assemblyai/sources/new-transcription-completed/new-transcription-completed.mjs index 69df9c21c519e..e3baa5c299765 100644 --- a/components/assemblyai/sources/new-transcription-completed/new-transcription-completed.mjs +++ b/components/assemblyai/sources/new-transcription-completed/new-transcription-completed.mjs @@ -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: { @@ -30,7 +30,7 @@ export default { return; } this._setLastId(transcripts[0].id); - transcripts.reverse().forEach((transcript) => this.emitEvent(transcript)); + await this.emitTranscripts(transcripts); }, }, methods: { @@ -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, @@ -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); }, }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 777d319172859..49796287db305 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10018,8 +10018,7 @@ importers: specifier: ^0.10.0 version: 0.10.0 - components/pdf_munk: - specifiers: {} + components/pdf_munk: {} components/pdffiller: dependencies: @@ -11686,8 +11685,7 @@ importers: specifier: ^0.10.0 version: 0.10.0 - components/rocketskip: - specifiers: {} + components/rocketskip: {} components/rockset: dependencies: @@ -12292,8 +12290,7 @@ importers: specifier: ^3.0.3 version: 3.0.3 - components/serenity_ai_hub: - specifiers: {} + components/serenity_ai_hub: {} components/serpapi: dependencies: @@ -13698,8 +13695,7 @@ importers: specifier: ^1.6.0 version: 1.6.6 - components/templatedocs: - specifiers: {} + components/templatedocs: {} components/tento8: {} @@ -14341,8 +14337,7 @@ importers: components/typebot: {} - components/typeflo: - specifiers: {} + components/typeflo: {} components/typeflowai: dependencies: