feat(media): 音频生成 - 支持 IndexTTS2 情感控制参数
This commit is contained in:
1 parent
a9c6e038e6
commit
6f3ca467c3
13 files changed
+266
-10
No files matched your search
@@ -7,7 +7,7 @@ import type { AiConfig } from "@/stores/use-config-store";
|
||||
|
||||
const speedOptions = ["0.75", "1", "1.25", "1.5"];
|
||||
|
||||
type AudioSettingKey = "audioVoice" | "audioFormat" | "audioSpeed" | "audioInstructions";
|
||||
type AudioSettingKey = "audioVoice" | "audioFormat" | "audioSpeed" | "audioInstructions" | "audioEmotionControlMethod" | "audioEmotionRandom" | "audioEmotionHappy" | "audioEmotionAngry" | "audioEmotionSad" | "audioEmotionAfraid" | "audioEmotionDisgusted" | "audioEmotionMelancholic" | "audioEmotionSurprised" | "audioEmotionCalm";
|
||||
|
||||
type AudioSettingsPanelProps = {
|
||||
config: AiConfig;
|
||||
@@ -75,11 +75,46 @@ export function AudioSettingsPanel({ config, onConfigChange, theme, showTitle =
|
||||
onMouseDown={(event) => event.stopPropagation()}
|
||||
/>
|
||||
</SettingGroup>
|
||||
<SettingGroup title="情感控制(IndexTTS2)" color={theme.node.muted}>
|
||||
<select
|
||||
className="h-9 w-full rounded-xl border bg-transparent px-3 text-sm outline-none"
|
||||
style={{ borderColor: theme.node.stroke, color: theme.node.text, background: theme.spatial.elevated }}
|
||||
value={config.audioEmotionControlMethod || "与音色参考音频相同"}
|
||||
onChange={(event) => onConfigChange("audioEmotionControlMethod", event.target.value)}
|
||||
onMouseDown={(event) => event.stopPropagation()}
|
||||
>
|
||||
<option value="与音色参考音频相同">与音色参考音频相同</option>
|
||||
<option value="使用情感参考音频">使用情感参考音频</option>
|
||||
</select>
|
||||
<label className="flex items-center justify-between gap-3 text-sm">
|
||||
<span>随机情感</span>
|
||||
<input type="checkbox" checked={config.audioEmotionRandom === "true"} onChange={(event) => onConfigChange("audioEmotionRandom", String(event.target.checked))} />
|
||||
</label>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
{emotionFields.map(([key, label]) => (
|
||||
<label key={key} className="flex items-center gap-2 text-xs">
|
||||
<span className="min-w-0 flex-1">{label}</span>
|
||||
<input type="number" min={0} max={1} step={0.01} className="h-8 w-20 rounded-lg border bg-transparent px-2 text-right outline-none" style={{ borderColor: theme.node.stroke, color: theme.node.text }} value={config[key] || "0"} onChange={(event) => onConfigChange(key, event.target.value)} onBlur={(event) => onConfigChange(key, normalizeEmotionWeight(event.target.value))} onMouseDown={(event) => event.stopPropagation()} />
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</SettingGroup>
|
||||
</div>
|
||||
</ImageSettingsTheme>
|
||||
);
|
||||
}
|
||||
|
||||
const emotionFields: Array<[Extract<AudioSettingKey, `audioEmotion${string}`>, string]> = [
|
||||
["audioEmotionHappy", "快乐"], ["audioEmotionAngry", "愤怒"], ["audioEmotionSad", "悲伤"], ["audioEmotionAfraid", "害怕"],
|
||||
["audioEmotionDisgusted", "厌恶"], ["audioEmotionMelancholic", "忧郁"], ["audioEmotionSurprised", "惊讶"], ["audioEmotionCalm", "平静"],
|
||||
];
|
||||
|
||||
function normalizeEmotionWeight(value: string) {
|
||||
const number = Number(value);
|
||||
if (!Number.isFinite(number)) return "0";
|
||||
return String(Math.max(0, Math.min(1, number)));
|
||||
}
|
||||
|
||||
function OptionPill({ selected, theme, onClick, children }: { selected: boolean; theme: CanvasTheme; onClick: () => void; children: ReactNode }) {
|
||||
return (
|
||||
<button
|
||||
|
||||
Reference in new issue
Block a user