Files
yaoyaoai/scripts/nodejs/voice_clone_enroll.js
949036910@qq.com d9c4e04d66 11
2026-05-29 23:16:52 +08:00

33 lines
957 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use strict";
/**
* 音色一键复刻(对齐 Electron ipc aliyun:cosyvoice:enroll
*/
const fs = require("fs");
const pipelineNative = require("./pipeline_native.js");
const desktopConfig = require("./desktop_config.js");
globalThis.__nodejsMain = async function main(params) {
const p = params || {};
const audioPath = String(p.audioPath || "").trim();
const name = String(p.name || "").trim();
if (!audioPath || !fs.existsSync(audioPath)) {
return { success: false, error: "请先录制或上传参考声音" };
}
if (!name) {
return { success: false, error: "请先输入音色名称" };
}
const apiKey =
desktopConfig.get("BAILIAN_API_KEY") ||
desktopConfig.get("DASHSCOPE_API_KEY");
if (!apiKey) {
return {
success: false,
error: "缺少 BAILIAN_API_KEY或 DASHSCOPE_API_KEY请在配置中设置",
};
}
return pipelineNative.qwenVoiceEnroll({ apiKey, audioPath, name });
};