Skip to content

Commit 698e80b

Browse files
committed
[Components] hamsa #16189
Actions - Transcribe Video - Create Content - Synthethize Voice
1 parent 4bfd583 commit 698e80b

File tree

6 files changed

+237
-148
lines changed

6 files changed

+237
-148
lines changed
Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { AI_PARTS_OPTIONS } from "../../common/constants.mjs";
12
import hamsa from "../../hamsa.app.mjs";
2-
import { axios } from "@pipedream/platform";
33

44
export default {
55
key: "hamsa-create-content",
@@ -9,42 +9,32 @@ export default {
99
type: "action",
1010
props: {
1111
hamsa,
12-
mediaUrl: {
12+
jobId: {
1313
propDefinition: [
1414
hamsa,
15-
"mediaUrl",
16-
],
17-
},
18-
webhookUrl: {
19-
propDefinition: [
20-
hamsa,
21-
"webhookUrl",
15+
"jobId",
2216
],
2317
},
2418
aiParts: {
25-
propDefinition: [
26-
hamsa,
27-
"aiParts",
28-
],
19+
type: "string[]",
20+
label: "AI Parts",
21+
description: "Parts for AI content in marketing.",
22+
options: AI_PARTS_OPTIONS,
2923
},
3024
},
3125
async run({ $ }) {
32-
const transcribeResponse = await this.hamsa.transcribeVideo({
33-
mediaUrl: this.mediaUrl,
34-
webhookUrl: this.webhookUrl,
35-
});
36-
37-
$.export("$summary", `Video transcription job created with ID: ${transcribeResponse.id}`);
38-
39-
const aiContentResponse = await this.hamsa.createAIContent({
40-
aiParts: this.aiParts,
26+
const response = await this.hamsa.createAIContent({
27+
$,
28+
params: {
29+
jobId: this.jobId,
30+
},
31+
data: {
32+
aiParts: this.aiParts,
33+
},
4134
});
4235

43-
$.export("$summary", `AI content creation job created with ID: ${aiContentResponse.id}`);
36+
$.export("$summary", `AI content creation job created with ID: ${response.data.id}`);
4437

45-
return {
46-
transcriptionJob: transcribeResponse,
47-
aiContentJob: aiContentResponse,
48-
};
38+
return response;
4939
},
5040
};

components/hamsa/actions/synthethize-voice/synthethize-voice.mjs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import hamsa from "../../hamsa.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "hamsa-synthesize-voice",
@@ -16,39 +15,49 @@ export default {
1615
],
1716
},
1817
text: {
19-
propDefinition: [
20-
hamsa,
21-
"text",
22-
],
18+
type: "string",
19+
label: "Text for TTS",
20+
description: "The text you want to convert to speech. Minimum 5 words required.",
2321
},
2422
webhookUrl: {
2523
propDefinition: [
2624
hamsa,
2725
"webhookUrl",
2826
],
27+
optional: true,
2928
},
30-
authKey: {
29+
webhookAuthKey: {
3130
type: "string",
3231
label: "Webhook Auth Key",
3332
description: "Authorization key for the webhook notifications.",
3433
optional: true,
3534
},
36-
authSecret: {
35+
webhookAuthSecret: {
3736
type: "string",
3837
label: "Webhook Auth Secret",
3938
description: "Authorization secret for the webhook notifications.",
4039
optional: true,
4140
},
4241
},
4342
async run({ $ }) {
44-
const response = await this.hamsa.generateTTS({
43+
const webhookAuth = {};
44+
if (this.webhookAuthKey) {
45+
webhookAuth.authKey = this.webhookAuthKey;
46+
}
47+
if (this.webhookAuthSecret) {
48+
webhookAuth.authSecret = this.webhookAuthSecret;
49+
}
50+
const data = {
4551
voiceId: this.voiceId,
4652
text: this.text,
4753
webhookUrl: this.webhookUrl,
48-
webhookAuth: {
49-
authKey: this.authKey,
50-
authSecret: this.authSecret,
51-
},
54+
};
55+
if (Object.keys(webhookAuth).length) {
56+
data.webhookAuth = webhookAuth;
57+
}
58+
const response = await this.hamsa.generateTTS({
59+
$,
60+
data,
5261
});
5362

5463
$.export("$summary", `Text to speech job successfully created with ID ${response.id}`);

components/hamsa/actions/transcribe-video/transcribe-video.mjs

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import {
2+
LANGUAGE_OPTIONS,
3+
MODEL_OPTIONS,
4+
} from "../../common/constants.mjs";
15
import hamsa from "../../hamsa.app.mjs";
2-
import { axios } from "@pipedream/platform";
36

47
export default {
58
key: "hamsa-transcribe-video",
@@ -10,16 +13,22 @@ export default {
1013
props: {
1114
hamsa,
1215
mediaUrl: {
13-
propDefinition: [
14-
hamsa,
15-
"mediaUrl",
16-
],
16+
type: "string",
17+
label: "Media URL",
18+
description: "The URL of the video to be transcribed.",
19+
},
20+
model: {
21+
type: "string",
22+
label: "Model",
23+
description: "The model you want to use to transcribe.",
24+
options: MODEL_OPTIONS,
1725
},
1826
webhookUrl: {
1927
propDefinition: [
2028
hamsa,
2129
"webhookUrl",
2230
],
31+
optional: true,
2332
},
2433
webhookAuthKey: {
2534
type: "string",
@@ -31,17 +40,46 @@ export default {
3140
type: "string",
3241
label: "Webhook Auth Secret",
3342
description: "The secret to use for authenticating the webhook.",
43+
secret: true,
44+
optional: true,
45+
},
46+
title: {
47+
type: "string",
48+
label: "Title",
49+
description: "The title of the transcription.",
50+
optional: true,
51+
},
52+
language: {
53+
type: "string",
54+
label: "Language",
55+
description: "The language of the transcription.",
56+
options: LANGUAGE_OPTIONS,
3457
optional: true,
3558
},
3659
},
3760
async run({ $ }) {
38-
const response = await this.hamsa.transcribeVideo({
61+
const webhookAuth = {};
62+
if (this.webhookAuthKey) {
63+
webhookAuth.authKey = this.webhookAuthKey;
64+
}
65+
if (this.webhookAuthSecret) {
66+
webhookAuth.authSecret = this.webhookAuthSecret;
67+
}
68+
const data = {
3969
mediaUrl: this.mediaUrl,
70+
model: this.model,
71+
processingType: "async",
4072
webhookUrl: this.webhookUrl,
41-
webhookAuth: {
42-
authKey: this.webhookAuthKey || null,
43-
authSecret: this.webhookAuthSecret || null,
44-
},
73+
title: this.title,
74+
language: this.language,
75+
};
76+
if (Object.keys(webhookAuth).length) {
77+
data.webhookAuth = webhookAuth;
78+
}
79+
80+
const response = await this.hamsa.transcribeVideo({
81+
$,
82+
data,
4583
});
4684

4785
$.export("$summary", "Transcription job started successfully.");
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
export const LIMIT = 100;
2+
3+
export const MODEL_OPTIONS = [
4+
{
5+
label: "Hamsa-General-V2.0 - Our most advanced ASR model, optimized for high accuracy across podcasts, videos, and general audio.",
6+
value: "Hamsa-General-V2.0",
7+
},
8+
{
9+
label: "Hamsa-Conversational-V1.0 - Best suited for conversational use cases, optimized for accurately transcribing phone calls and meetings.",
10+
value: "Hamsa-Conversational-V1.0",
11+
},
12+
];
13+
14+
export const LANGUAGE_OPTIONS = [
15+
"ar",
16+
"en",
17+
];
18+
19+
export const AI_PARTS_OPTIONS = [
20+
{
21+
label: "Introduction",
22+
value: "introduction",
23+
},
24+
{
25+
label: "Titles",
26+
value: "titles",
27+
},
28+
{
29+
label: "Summary",
30+
value: "summary",
31+
},
32+
{
33+
label: "Web Article SEO Friendly",
34+
value: "webArticleSEOFriendly",
35+
},
36+
{
37+
label: "Key Topics With Bullets",
38+
value: "keyTopicsWithBullets",
39+
},
40+
{
41+
label: "Keywords",
42+
value: "keywords",
43+
},
44+
{
45+
label: "Threads By Instagram",
46+
value: "threadsByInstagram",
47+
},
48+
{
49+
label: "FAQ",
50+
value: "faq",
51+
},
52+
{
53+
label: "Facebook Post",
54+
value: "facebookPost",
55+
},
56+
{
57+
label: "YouTube Description",
58+
value: "youtubeDescription",
59+
},
60+
{
61+
label: "Twitter Thread",
62+
value: "twitterThread",
63+
},
64+
{
65+
label: "LinkedIn Post",
66+
value: "linkedInPost",
67+
},
68+
];

0 commit comments

Comments
 (0)