UNPKG

@wiro-ai/n8n-nodes-wiroai

Version:

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

143 lines 6.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Mmaudio = void 0; const n8n_workflow_1 = require("n8n-workflow"); const auth_1 = require("../utils/auth"); const polling_1 = require("../utils/polling"); class Mmaudio { constructor() { this.description = { displayName: 'Wiro - MMAudio - Video to Audio Generator', name: 'mmaudio', icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' }, group: ['transform'], version: 1, description: 'MMAudio generates synchronized audio for videos using AI. Enhance video content with matching s', defaults: { name: 'Wiro - MMAudio - Video to Audio Generator', }, 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: 'Upload a video file to generate synchronized audio. The model will analyze visual content and create matching sound effects. Maximum 30 seconds. If no video is provided, the model switches to text-to-audio mode', }, { displayName: 'Prompt', name: 'prompt', type: 'string', default: '', description: 'Describe the audio you want to generate. For video input: enhances the generated audio with specific sounds or leave empty. For text-to-audio mode: required description of the audio to create', }, { displayName: 'Negativeprompt', name: 'negativePrompt', type: 'string', default: '', description: 'Describe sounds to avoid in the generated audio. Helps filter out unwanted elements like background noise, distortion, or specific sounds you don\'t want.', }, { displayName: 'Inferencesteps', name: 'steps', type: 'number', default: 0, description: 'Number of denoising steps. Higher values produce better quality audio but take longer.', }, { displayName: 'Duration', name: 'duration', type: 'number', default: 0, description: 'Audio duration in seconds. Only used in text-to-audio mode (when no video is provided). When a video is uploaded, duration is automatically set to match the video length', }, { displayName: 'Strength', name: 'strength', type: 'number', default: 0, description: 'Controls how strongly the model follows the text prompt. Higher values = more prompt influence. Lower values = more natural/subtle results. Recommended: 4.0-5.0', }, { displayName: 'Seed', name: 'seed', type: 'string', default: '', description: 'Random seed for reproducibility. Use the same seed to generate identical results. Change for variations', }, ], }; } async execute() { const returnData = []; const inputVideoUrl = this.getNodeParameter('inputVideoUrl', 0, ''); const prompt = this.getNodeParameter('prompt', 0, ''); const negativePrompt = this.getNodeParameter('negativePrompt', 0, ''); const steps = this.getNodeParameter('steps', 0, 0); const duration = this.getNodeParameter('duration', 0, 0); const strength = this.getNodeParameter('strength', 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/mmaudio', headers: { ...headers, 'Content-Type': 'application/json', }, body: { inputVideoUrl, prompt, negativePrompt, steps, duration, strength, 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.Mmaudio = Mmaudio; //# sourceMappingURL=Mmaudio.node.js.map