feat: convert guidance inputs to static text labels using custom JS extension
This commit is contained in:
@@ -481,9 +481,9 @@ class AIIA_CosyVoice_TTS:
|
||||
return {
|
||||
"required": {
|
||||
"model": ("COSYVOICE_MODEL",),
|
||||
"提示1_说的内容": ("STRING", {"default": "📖 第一步:在此输入您想让 AI 说的话 (TTS Text)", "multiline": False}),
|
||||
"提示1_说的内容": ("AIIA_LABEL", {"default": "📖 第一步:在此输入您想让 AI 说的话 (TTS Text)"}),
|
||||
"tts_text": ("STRING", {"multiline": True, "default": "你好,这是 CosyVoice 3.0 的全能模式测试。"}),
|
||||
"提示2_音色描述": ("STRING", {"default": "🎨 第二步:在此输入对声音的文字描述 (Voice Description)", "multiline": False}),
|
||||
"提示2_音色描述": ("AIIA_LABEL", {"default": "🎨 第二步:在此输入对声音的文字描述 (Voice Description)"}),
|
||||
"instruct_text": ("STRING", {"multiline": True, "default": "一个沉稳、磁性的成熟男性声音,语法标准,情感饱满。"}),
|
||||
"spk_id": ("STRING", {"default": "", "tooltip": "固定音色 ID (如 pure_1)。对于 0.5B/V3 等 Zero-Shot 模型,此项通常为空,需配合参考音频使用。"}),
|
||||
"speed": ("FLOAT", {"default": 1.0, "min": 0.5, "max": 2.0, "step": 0.1}),
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
|
||||
import { app } from "../../../scripts/app.js";
|
||||
|
||||
// Extension to handle static labels (AIIA_LABEL)
|
||||
app.registerExtension({
|
||||
name: "AIIA.Labels",
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
// Iterate through inputs to find ones marked as AIIA_LABEL
|
||||
const allInputs = { ...nodeData.input?.required, ...nodeData.input?.optional };
|
||||
|
||||
let hasLabel = false;
|
||||
for (const [name, input] of Object.entries(allInputs)) {
|
||||
if (input[0] === "AIIA_LABEL") {
|
||||
hasLabel = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasLabel) {
|
||||
// Hijack onNodeCreated to style our label widgets
|
||||
const onNodeCreated = nodeType.prototype.onNodeCreated;
|
||||
nodeType.prototype.onNodeCreated = function () {
|
||||
const r = onNodeCreated ? onNodeCreated.apply(this, arguments) : undefined;
|
||||
|
||||
for (const w of this.widgets) {
|
||||
// Check if this widget was defined as AIIA_LABEL in Python
|
||||
// Since nodeData.input is available, we can verify by name
|
||||
const inputDef = allInputs[w.name];
|
||||
if (inputDef && inputDef[0] === "AIIA_LABEL") {
|
||||
w.type = "text"; // Change to text so it renders
|
||||
w.draw = function (ctx, node, widget_width, y, widget_height) {
|
||||
const show_text = true;
|
||||
const outline_color = app.canvas.ds.outline_color;
|
||||
|
||||
ctx.save();
|
||||
ctx.fillStyle = "#AAAAAA"; // Label color
|
||||
ctx.font = "italic 12px Arial";
|
||||
// Center or offset as needed
|
||||
ctx.fillText(this.value, 15, y + widget_height * 0.7);
|
||||
ctx.restore();
|
||||
};
|
||||
// Disable interaction
|
||||
w.mouse = () => { };
|
||||
w.computeSize = () => [200, 20];
|
||||
}
|
||||
}
|
||||
return r;
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user