Skip to content

Commit 4bfd583

Browse files
committed
hamsa init
1 parent 2f3a00e commit 4bfd583

File tree

5 files changed

+292
-6
lines changed

5 files changed

+292
-6
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import hamsa from "../../hamsa.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "hamsa-create-content",
6+
name: "Create AI Content",
7+
description: "Transform transcribed content into various formats for content marketing. [See the documentation](https://docs.tryhamsa.com/api-reference/endpoint/post-ai-content)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
hamsa,
12+
mediaUrl: {
13+
propDefinition: [
14+
hamsa,
15+
"mediaUrl",
16+
],
17+
},
18+
webhookUrl: {
19+
propDefinition: [
20+
hamsa,
21+
"webhookUrl",
22+
],
23+
},
24+
aiParts: {
25+
propDefinition: [
26+
hamsa,
27+
"aiParts",
28+
],
29+
},
30+
},
31+
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,
41+
});
42+
43+
$.export("$summary", `AI content creation job created with ID: ${aiContentResponse.id}`);
44+
45+
return {
46+
transcriptionJob: transcribeResponse,
47+
aiContentJob: aiContentResponse,
48+
};
49+
},
50+
};
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import hamsa from "../../hamsa.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "hamsa-synthesize-voice",
6+
name: "Synthesize Voice",
7+
description: "Converts text input into artificial speech using Hamsa. [See the documentation](https://docs.tryhamsa.com/api-reference/endpoint/generate-tts)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
hamsa,
12+
voiceId: {
13+
propDefinition: [
14+
hamsa,
15+
"voiceId",
16+
],
17+
},
18+
text: {
19+
propDefinition: [
20+
hamsa,
21+
"text",
22+
],
23+
},
24+
webhookUrl: {
25+
propDefinition: [
26+
hamsa,
27+
"webhookUrl",
28+
],
29+
},
30+
authKey: {
31+
type: "string",
32+
label: "Webhook Auth Key",
33+
description: "Authorization key for the webhook notifications.",
34+
optional: true,
35+
},
36+
authSecret: {
37+
type: "string",
38+
label: "Webhook Auth Secret",
39+
description: "Authorization secret for the webhook notifications.",
40+
optional: true,
41+
},
42+
},
43+
async run({ $ }) {
44+
const response = await this.hamsa.generateTTS({
45+
voiceId: this.voiceId,
46+
text: this.text,
47+
webhookUrl: this.webhookUrl,
48+
webhookAuth: {
49+
authKey: this.authKey,
50+
authSecret: this.authSecret,
51+
},
52+
});
53+
54+
$.export("$summary", `Text to speech job successfully created with ID ${response.id}`);
55+
return response;
56+
},
57+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import hamsa from "../../hamsa.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "hamsa-transcribe-video",
6+
name: "Transcribe Video",
7+
description: "Automatically transcribe Arabic videos from YouTube URLs or direct links. [See the documentation](https://docs.tryhamsa.com/api-reference/endpoint/transcribe)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
hamsa,
12+
mediaUrl: {
13+
propDefinition: [
14+
hamsa,
15+
"mediaUrl",
16+
],
17+
},
18+
webhookUrl: {
19+
propDefinition: [
20+
hamsa,
21+
"webhookUrl",
22+
],
23+
},
24+
webhookAuthKey: {
25+
type: "string",
26+
label: "Webhook Auth Key",
27+
description: "The key to use for authenticating the webhook.",
28+
optional: true,
29+
},
30+
webhookAuthSecret: {
31+
type: "string",
32+
label: "Webhook Auth Secret",
33+
description: "The secret to use for authenticating the webhook.",
34+
optional: true,
35+
},
36+
},
37+
async run({ $ }) {
38+
const response = await this.hamsa.transcribeVideo({
39+
mediaUrl: this.mediaUrl,
40+
webhookUrl: this.webhookUrl,
41+
webhookAuth: {
42+
authKey: this.webhookAuthKey || null,
43+
authSecret: this.webhookAuthSecret || null,
44+
},
45+
});
46+
47+
$.export("$summary", "Transcription job started successfully.");
48+
return response;
49+
},
50+
};

components/hamsa/hamsa.app.mjs

Lines changed: 134 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,140 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "hamsa",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
mediaUrl: {
8+
type: "string",
9+
label: "Media URL",
10+
description: "The URL of the video to be transcribed.",
11+
},
12+
voiceId: {
13+
type: "string",
14+
label: "Voice ID",
15+
description: "The voice ID for Text to Speech conversion.",
16+
},
17+
text: {
18+
type: "string",
19+
label: "Text for TTS",
20+
description: "The text you want to convert to speech. Minimum 5 words required.",
21+
},
22+
webhookUrl: {
23+
type: "string",
24+
label: "Webhook URL",
25+
description: "The URL to receive the webhook notifications.",
26+
},
27+
aiParts: {
28+
type: "string[]",
29+
label: "AI Parts",
30+
description: "Parts for AI content in marketing, e.g., introduction, titles, etc.",
31+
async options() {
32+
return [
33+
{
34+
label: "Introduction",
35+
value: "introduction",
36+
},
37+
{
38+
label: "Titles",
39+
value: "titles",
40+
},
41+
{
42+
label: "Summary",
43+
value: "summary",
44+
},
45+
{
46+
label: "Web Article SEO Friendly",
47+
value: "webArticleSEOFriendly",
48+
},
49+
{
50+
label: "Key Topics With Bullets",
51+
value: "keyTopicsWithBullets",
52+
},
53+
{
54+
label: "Keywords",
55+
value: "keywords",
56+
},
57+
{
58+
label: "Threads By Instagram",
59+
value: "threadsByInstagram",
60+
},
61+
{
62+
label: "FAQ",
63+
value: "faq",
64+
},
65+
{
66+
label: "Facebook Post",
67+
value: "facebookPost",
68+
},
69+
{
70+
label: "YouTube Description",
71+
value: "youtubeDescription",
72+
},
73+
{
74+
label: "Twitter Thread",
75+
value: "twitterThread",
76+
},
77+
{
78+
label: "LinkedIn Post",
79+
value: "linkedInPost",
80+
},
81+
];
82+
},
83+
},
84+
},
585
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
86+
_baseUrl() {
87+
return "https://api.tryhamsa.com/v1";
88+
},
89+
async _makeRequest(opts = {}) {
90+
const {
91+
$ = this, method = "POST", path = "/", headers, ...otherOpts
92+
} = opts;
93+
return axios($, {
94+
...otherOpts,
95+
method,
96+
url: this._baseUrl() + path,
97+
headers: {
98+
...headers,
99+
Authorization: `Token ${this.$auth.api_key}`,
100+
},
101+
});
102+
},
103+
async transcribeVideo({
104+
mediaUrl, webhookUrl, webhookAuth,
105+
}) {
106+
return this._makeRequest({
107+
path: "/jobs/transcribe",
108+
data: {
109+
mediaUrl,
110+
processingType: "async",
111+
webhookUrl,
112+
webhookAuth,
113+
model: "Hamsa-General-V2.0",
114+
language: "ar",
115+
},
116+
});
117+
},
118+
async generateTTS({
119+
voiceId, text, webhookUrl, webhookAuth,
120+
}) {
121+
return this._makeRequest({
122+
path: "/jobs/text-to-speech",
123+
data: {
124+
voiceId,
125+
text,
126+
webhookUrl,
127+
webhookAuth,
128+
},
129+
});
130+
},
131+
async createAIContent({ aiParts }) {
132+
return this._makeRequest({
133+
path: "/jobs/ai-content",
134+
data: {
135+
aiParts,
136+
},
137+
});
9138
},
10139
},
11-
};
140+
};

components/hamsa/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"publishConfig": {
1313
"access": "public"
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)