Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
40 changes: 40 additions & 0 deletions components/hamsa/actions/create-content/create-content.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { AI_PARTS_OPTIONS } from "../../common/constants.mjs";
import hamsa from "../../hamsa.app.mjs";

export default {
key: "hamsa-create-content",
name: "Create AI Content",
description: "Transform transcribed content into various formats for content marketing. [See the documentation](https://docs.tryhamsa.com/api-reference/endpoint/post-ai-content)",
version: "0.0.1",
type: "action",
props: {
hamsa,
jobId: {
propDefinition: [
hamsa,
"jobId",
],
},
aiParts: {
type: "string[]",
label: "AI Parts",
description: "Parts for AI content in marketing.",
options: AI_PARTS_OPTIONS,
},
},
async run({ $ }) {
const response = await this.hamsa.createAIContent({
$,
params: {
jobId: this.jobId,
},
data: {
aiParts: this.aiParts,
},
});

$.export("$summary", `AI content creation job created with ID: ${response.data.id}`);

return response;
},
};
21 changes: 21 additions & 0 deletions components/hamsa/actions/list-jobs/list-jobs.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import hamsa from "../../hamsa.app.mjs";

export default {
key: "hamsa-list-jobs",
name: "List Jobs",
description: "Fetch the list of jobs from Hamsa. [See the documentation](https://docs.tryhamsa.com/api-reference/endpoint/get-jobs-list)",
version: "0.0.1",
type: "action",
props: {
hamsa,
},
async run({ $ }) {
const response = await this.hamsa.listJobs({
$,
});

$.export("$summary", `Successfully fetched ${response?.data?.jobs?.legnth} jobs.`);

return response;
},
};
66 changes: 66 additions & 0 deletions components/hamsa/actions/synthethize-voice/synthethize-voice.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import hamsa from "../../hamsa.app.mjs";

export default {
key: "hamsa-synthethize-voice",
name: "Synthethize Voice",
description: "Converts text input into artificial speech using Hamsa. [See the documentation](https://docs.tryhamsa.com/api-reference/endpoint/generate-tts)",
version: "0.0.1",
type: "action",
props: {
hamsa,
voiceId: {
propDefinition: [
hamsa,
"voiceId",
],
},
text: {
type: "string",
label: "Text for TTS",
description: "The text you want to convert to speech. Minimum 5 words required.",
},
webhookUrl: {
propDefinition: [
hamsa,
"webhookUrl",
],
optional: true,
},
webhookAuthKey: {
type: "string",
label: "Webhook Auth Key",
description: "Authorization key for the webhook notifications.",
optional: true,
},
webhookAuthSecret: {
type: "string",
label: "Webhook Auth Secret",
description: "Authorization secret for the webhook notifications.",
optional: true,
},
},
async run({ $ }) {
const webhookAuth = {};
if (this.webhookAuthKey) {
webhookAuth.authKey = this.webhookAuthKey;
}
if (this.webhookAuthSecret) {
webhookAuth.authSecret = this.webhookAuthSecret;
}
const data = {
voiceId: this.voiceId,
text: this.text,
webhookUrl: this.webhookUrl,
};
if (Object.keys(webhookAuth).length) {
data.webhookAuth = webhookAuth;
}
const response = await this.hamsa.generateTTS({
$,
data,
});

$.export("$summary", `Text to speech job successfully created with ID ${response.id}`);
return response;
},
};
88 changes: 88 additions & 0 deletions components/hamsa/actions/transcribe-video/transcribe-video.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import {
LANGUAGE_OPTIONS,
MODEL_OPTIONS,
} from "../../common/constants.mjs";
import hamsa from "../../hamsa.app.mjs";

export default {
key: "hamsa-transcribe-video",
name: "Transcribe Video",
description: "Automatically transcribe Arabic videos from YouTube URLs or direct links. [See the documentation](https://docs.tryhamsa.com/api-reference/endpoint/transcribe)",
version: "0.0.1",
type: "action",
props: {
hamsa,
mediaUrl: {
type: "string",
label: "Media URL",
description: "The URL of the video to be transcribed.",
},
model: {
type: "string",
label: "Model",
description: "The model you want to use to transcribe.",
options: MODEL_OPTIONS,
},
webhookUrl: {
propDefinition: [
hamsa,
"webhookUrl",
],
optional: true,
},
webhookAuthKey: {
type: "string",
label: "Webhook Auth Key",
description: "The key to use for authenticating the webhook.",
optional: true,
},
webhookAuthSecret: {
type: "string",
label: "Webhook Auth Secret",
description: "The secret to use for authenticating the webhook.",
secret: true,
optional: true,
},
title: {
type: "string",
label: "Title",
description: "The title of the transcription.",
optional: true,
},
language: {
type: "string",
label: "Language",
description: "The language of the transcription.",
options: LANGUAGE_OPTIONS,
optional: true,
},
},
async run({ $ }) {
const webhookAuth = {};
if (this.webhookAuthKey) {
webhookAuth.authKey = this.webhookAuthKey;
}
if (this.webhookAuthSecret) {
webhookAuth.authSecret = this.webhookAuthSecret;
}
const data = {
mediaUrl: this.mediaUrl,
model: this.model,
processingType: "async",
webhookUrl: this.webhookUrl,
title: this.title,
language: this.language,
};
if (Object.keys(webhookAuth).length) {
data.webhookAuth = webhookAuth;
}

const response = await this.hamsa.transcribeVideo({
$,
data,
});

$.export("$summary", "Transcription job started successfully.");
return response;
},
};
68 changes: 68 additions & 0 deletions components/hamsa/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
export const LIMIT = 100;

export const MODEL_OPTIONS = [
{
label: "Hamsa-General-V2.0 - Our most advanced ASR model, optimized for high accuracy across podcasts, videos, and general audio.",
value: "Hamsa-General-V2.0",
},
{
label: "Hamsa-Conversational-V1.0 - Best suited for conversational use cases, optimized for accurately transcribing phone calls and meetings.",
value: "Hamsa-Conversational-V1.0",
},
];

export const LANGUAGE_OPTIONS = [
"ar",
"en",
];

export const AI_PARTS_OPTIONS = [
{
label: "Introduction",
value: "introduction",
},
{
label: "Titles",
value: "titles",
},
{
label: "Summary",
value: "summary",
},
{
label: "Web Article SEO Friendly",
value: "webArticleSEOFriendly",
},
{
label: "Key Topics With Bullets",
value: "keyTopicsWithBullets",
},
{
label: "Keywords",
value: "keywords",
},
{
label: "Threads By Instagram",
value: "threadsByInstagram",
},
{
label: "FAQ",
value: "faq",
},
{
label: "Facebook Post",
value: "facebookPost",
},
{
label: "YouTube Description",
value: "youtubeDescription",
},
{
label: "Twitter Thread",
value: "twitterThread",
},
{
label: "LinkedIn Post",
value: "linkedInPost",
},
];
Loading
Loading