@wiro-ai/n8n-nodes-wiroai
Version:
n8n community node for Wiro AI — 290+ AI models: video, image, audio, LLM, 3D, and more.
136 lines • 5.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.VoiceClone = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const auth_1 = require("../utils/auth");
const polling_1 = require("../utils/polling");
class VoiceClone {
constructor() {
this.description = {
displayName: 'Wiro - Voice Clone',
name: 'voiceClone',
icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' },
group: ['transform'],
version: 1,
description: 'A text-to-speech tool by Coqui that generates natural-sounding speech from text and performs vo',
defaults: {
name: 'Wiro - Voice Clone',
},
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-help',
},
{
displayName: 'Prompt',
name: 'prompt',
type: 'string',
default: '',
required: true,
description: 'Prompt-help',
},
{
displayName: 'Temp',
name: 'temp',
type: 'number',
default: 0,
description: 'Temp-help',
},
{
displayName: 'Language',
name: 'language',
type: 'options',
default: 'ar',
description: 'Scheduler-help',
options: [
{ name: 'Arabic', value: 'ar' },
{ name: 'Chinese', value: 'zh-cn' },
{ name: 'Czech', value: 'cs' },
{ name: 'Dutch', value: 'nl' },
{ name: 'English', value: 'en' },
{ name: 'French', value: 'fr' },
{ name: 'German', value: 'de' },
{ name: 'Hindi', value: 'hi' },
{ name: 'Hungarian', value: 'hu' },
{ name: 'Italian', value: 'it' },
{ name: 'Japanese', value: 'ja' },
{ name: 'Korean', value: 'ko' },
{ name: 'Polish', value: 'pl' },
{ name: 'Portuguese', value: 'pt' },
{ name: 'Russian', value: 'ru' },
{ name: 'Spanish', value: 'es' },
{ name: 'Turkish', value: 'tr' },
],
},
],
};
}
async execute() {
const returnData = [];
const inputAudioUrl = this.getNodeParameter('inputAudioUrl', 0, '');
const prompt = this.getNodeParameter('prompt', 0);
const temp = this.getNodeParameter('temp', 0, 0);
const language = this.getNodeParameter('language', 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/voice-clone',
headers: {
...headers,
'Content-Type': 'application/json',
},
body: {
inputAudioUrl,
prompt,
temp,
language,
},
});
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.VoiceClone = VoiceClone;
//# sourceMappingURL=VoiceClone.node.js.map