UNPKG

@wiro-ai/n8n-nodes-wiroai

Version:

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

187 lines 7.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ImageToSongWithReferenceYue = void 0; const n8n_workflow_1 = require("n8n-workflow"); const auth_1 = require("../utils/auth"); const polling_1 = require("../utils/polling"); class ImageToSongWithReferenceYue { constructor() { this.description = { displayName: 'Wiro - Image To Song With Reference Yue', name: 'imageToSongWithReferenceYue', icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' }, group: ['transform'], version: 1, description: 'Turn any song into your own with AI. Simply upload a reference track and provide your image — A', defaults: { name: 'Wiro - Image To Song With Reference Yue', }, inputs: [n8n_workflow_1.NodeConnectionTypes.Main], outputs: [n8n_workflow_1.NodeConnectionTypes.Main], usableAsTool: true, credentials: [ { name: 'wiroApi', required: true, }, ], properties: [ { displayName: 'Input Image URL', name: 'inputImageUrl', type: 'string', default: '', description: 'Init-image-help', }, { displayName: 'Reference Song URL', name: 'inputAudioUrl', type: 'string', default: '', description: 'Upload a reference song that captures the style, vibe, or sound you want. AI will use this track as inspiration to recreate your lyrics in a similar musical style.', }, { displayName: 'Reference Song Clone Type', name: 'audio_prompt_type', type: 'options', default: 'both', required: true, description: 'Vocal: Clone the vocal style and melody of your reference song, but generate a new instrumental. Instrumental: Clone the instrumental style and structure, but generate new vocals from your lyrics. Both: Clone both the vocal style and instrumental feel to closely match your reference song while using your custom lyrics', options: [ { name: 'Both', value: 'both' }, { name: 'Instrumental', value: 'instrumental' }, { name: 'Vocal', value: 'vocal' }, ], }, { displayName: 'Genre', name: 'genre', type: 'multiOptions', default: [], required: true, description: 'Select one or more values for genre', options: [ { name: '', value: '' }, ], }, { displayName: 'Instrument', name: 'instrument', type: 'multiOptions', default: [], required: true, description: 'Select one or more values for instrument', options: [ { name: '', value: '' }, ], }, { displayName: 'Mood', name: 'mood', type: 'multiOptions', default: [], required: true, description: 'Select one or more values for mood', options: [ { name: '', value: '' }, ], }, { displayName: 'Gender', name: 'gender', type: 'multiOptions', default: [], required: true, description: 'Select one or more values for gender', options: [ { name: '', value: '' }, ], }, { displayName: 'Timbre', name: 'timbre', type: 'multiOptions', default: [], required: true, description: 'Select one or more values for timbre', options: [ { name: '', value: '' }, ], }, { displayName: 'Seed', name: 'seed', type: 'string', default: '', description: 'Seed-help', }, ], }; } async execute() { const returnData = []; const inputImageUrl = this.getNodeParameter('inputImageUrl', 0, ''); const inputAudioUrl = this.getNodeParameter('inputAudioUrl', 0, ''); const audio_prompt_type = this.getNodeParameter('audio_prompt_type', 0); const genre = this.getNodeParameter('genre', 0); const instrument = this.getNodeParameter('instrument', 0); const mood = this.getNodeParameter('mood', 0); const gender = this.getNodeParameter('gender', 0); const timbre = this.getNodeParameter('timbre', 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/image-to-song-with-reference-YuE', headers: { ...headers, 'Content-Type': 'application/json', }, body: { inputImageUrl, inputAudioUrl, audio_prompt_type, genre, instrument, mood, gender, timbre, 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.ImageToSongWithReferenceYue = ImageToSongWithReferenceYue; //# sourceMappingURL=ImageToSongWithReferenceYue.node.js.map