UNPKG

@wiro-ai/n8n-nodes-wiroai

Version:

n8n community node for Wiro AI — 290+ AI models: video, image, audio, LLM, 3D, and more.

134 lines 5.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.VideoBackgroundMusic2 = void 0; const n8n_workflow_1 = require("n8n-workflow"); const auth_1 = require("../utils/auth"); const polling_1 = require("../utils/polling"); class VideoBackgroundMusic2 { constructor() { this.description = { displayName: 'Wiro - Video Background Music V2', name: 'videoBackgroundMusic2', icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' }, group: ['transform'], version: 1, description: 'It turns any video into a cinematic experience by generating AI-powered instrumental soundtrack', defaults: { name: 'Wiro - Video Background Music V2', }, 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: 'Provide a video file or a video URL', }, { displayName: 'Caption', name: 'caption', type: 'string', default: '', description: 'Free-text description of the desired music. If no caption is provided, the video is automatically analyzed to create a fitting music description.', }, { displayName: 'Reference Audio URL', name: 'inputAudioUrl', type: 'string', default: '', description: 'Upload a song to use as style inspiration', }, { displayName: 'Bpm', name: 'bpm', type: 'number', default: 0, description: 'Set the tempo (e.g. 80 for slow ballad, 128 for dance). Leave 0 to let AI decide. Default: 0', }, { displayName: 'Background Music Volume', name: 'bgMusicVolume', type: 'number', default: 0, description: 'Controls the relative volume of the generated background music', }, { displayName: 'Seed', name: 'seed', type: 'string', default: '', description: 'Seed-help', }, ], }; } async execute() { const returnData = []; const inputVideoUrl = this.getNodeParameter('inputVideoUrl', 0, ''); const caption = this.getNodeParameter('caption', 0, ''); const inputAudioUrl = this.getNodeParameter('inputAudioUrl', 0, ''); const bpm = this.getNodeParameter('bpm', 0, 0); const bgMusicVolume = this.getNodeParameter('bgMusicVolume', 0, 0); const seed = this.getNodeParameter('seed', 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-v2', headers: { ...headers, 'Content-Type': 'application/json', }, body: { inputVideoUrl, caption, inputAudioUrl, bpm, bgMusicVolume, seed, }, }); 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.VideoBackgroundMusic2 = VideoBackgroundMusic2; //# sourceMappingURL=VideoBackgroundMusic2.node.js.map