@wiro-ai/n8n-nodes-wiroai
Version:
n8n community node for Wiro AI — 290+ AI models: video, image, audio, LLM, 3D, and more.
125 lines • 4.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.VideoBackgroundMusicGen = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const auth_1 = require("../utils/auth");
const polling_1 = require("../utils/polling");
class VideoBackgroundMusicGen {
constructor() {
this.description = {
displayName: 'Wiro - Video Background Music Gen',
name: 'videoBackgroundMusicGen',
icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' },
group: ['transform'],
version: 1,
description: 'It’s a tool that gets your video, creates original music to match its vibe, and seamlessly adds',
defaults: {
name: 'Wiro - Video Background Music Gen',
},
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
usableAsTool: true,
credentials: [
{
name: 'wiroApi',
required: true,
},
],
properties: [
{
displayName: 'Input Video URL',
name: 'inputVideoUrl',
type: 'string',
default: '',
description: 'Input-video-help',
},
{
displayName: 'Prompt',
name: 'prompt',
type: 'string',
default: '',
description: 'Text input for prompt',
},
{
displayName: 'Tokens',
name: 'generationLength',
type: 'number',
default: 0,
description: 'Max number of tokens to generate',
},
{
displayName: 'Guidance Scale',
name: 'scale',
type: 'number',
default: 0,
description: 'Guidancescale-help',
},
{
displayName: 'Bg Music Volume',
name: 'bgMusicVolume',
type: 'number',
default: 0,
description: 'Controls the relative volume of the generated background music',
},
],
};
}
async execute() {
const returnData = [];
const inputVideoUrl = this.getNodeParameter('inputVideoUrl', 0, '');
const prompt = this.getNodeParameter('prompt', 0, '');
const generationLength = this.getNodeParameter('generationLength', 0, 0);
const scale = this.getNodeParameter('scale', 0, 0);
const bgMusicVolume = this.getNodeParameter('bgMusicVolume', 0, 0);
const credentials = await this.getCredentials('wiroApi');
const apiKey = credentials.apiKey;
const apiSecret = credentials.apiSecret;
const headers = (0, auth_1.generateWiroAuthHeaders)(apiKey, apiSecret);
const response = await this.helpers.httpRequest({
method: 'POST',
url: 'https://api.wiro.ai/v1/Run/wiro/video-background-music-gen',
headers: {
...headers,
'Content-Type': 'application/json',
},
body: {
inputVideoUrl,
prompt,
tokens: generationLength,
scale,
bgMusicVolume,
},
});
if (!(response === null || response === void 0 ? void 0 : response.taskid) || !(response === null || response === void 0 ? void 0 : response.socketaccesstoken)) {
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
message: 'Wiro API did not return a valid task ID or socket access token ' +
JSON.stringify(response),
});
}
const taskid = response.taskid;
const socketaccesstoken = response.socketaccesstoken;
const result = await polling_1.pollTaskUntilComplete.call(this, socketaccesstoken, headers);
const responseJSON = {
taskid: taskid,
url: '',
status: '',
};
switch (result) {
case '-1':
case '-2':
case '-3':
case '-4':
responseJSON.status = 'failed';
break;
default:
responseJSON.status = 'completed';
responseJSON.url = result !== null && result !== void 0 ? result : '';
}
returnData.push({
json: responseJSON,
});
return [returnData];
}
}
exports.VideoBackgroundMusicGen = VideoBackgroundMusicGen;
//# sourceMappingURL=VideoBackgroundMusicGen.node.js.map