UNPKG

@wiro-ai/n8n-nodes-wiroai

Version:

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

127 lines 4.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Voxcpm = void 0; const n8n_workflow_1 = require("n8n-workflow"); const auth_1 = require("../utils/auth"); const polling_1 = require("../utils/polling"); class Voxcpm { constructor() { this.description = { displayName: 'Wiro - Voxcpm', name: 'voxcpm', icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' }, group: ['transform'], version: 1, description: 'Tokenizer-Free TTS for Context-Aware Speech Generation and True-to-Life Voice Cloning', defaults: { name: 'Wiro - Voxcpm', }, inputs: [n8n_workflow_1.NodeConnectionTypes.Main], outputs: [n8n_workflow_1.NodeConnectionTypes.Main], usableAsTool: true, credentials: [ { name: 'wiroApi', required: true, }, ], properties: [ { displayName: 'Input Audio URL', name: 'inputAudioUrl', type: 'string', default: '', description: 'Input Audio and Reference Audio Text must both be provided or both be None', }, { displayName: 'Reference Audio Text', name: 'referencePrompt', type: 'string', default: '', description: 'Input Audio and Reference Audio Text must both be provided or both be None', }, { displayName: 'Prompt', name: 'prompt', type: 'string', default: '', required: true, description: 'Prompt-help', }, { displayName: 'Cfg Value', name: 'cfgValue', type: 'number', default: 0, required: true, description: 'LM guidance on LocDiT, higher for better adherence to the prompt, but maybe worse', }, { displayName: 'Inference Steps', name: 'inferenceSteps', type: 'number', default: 0, description: 'LocDiT inference timesteps, higher for better result, lower for fast speed', }, ], }; } async execute() { const returnData = []; const inputAudioUrl = this.getNodeParameter('inputAudioUrl', 0, ''); const referencePrompt = this.getNodeParameter('referencePrompt', 0, ''); const prompt = this.getNodeParameter('prompt', 0); const cfgValue = this.getNodeParameter('cfgValue', 0); const inferenceSteps = this.getNodeParameter('inferenceSteps', 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/openbmb/VoxCPM', headers: { ...headers, 'Content-Type': 'application/json', }, body: { inputAudioUrl, referencePrompt, prompt, cfgValue, inferenceSteps, }, }); 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.Voxcpm = Voxcpm; //# sourceMappingURL=Voxcpm.node.js.map