import RefreshIcon from '@mui/icons-material/Refresh'; import { Box, FormControl, IconButton, Input, InputLabel, MenuItem, Paper, Select, Slider, Tooltip, Typography, } from '@mui/material'; import Grid from '@mui/material/Unstable_Grid2/Grid2'; import { useState } from 'react'; import type { LineState, ModelInfo } from './EditorContainer'; import { defaultLineState } from './EditorContainer'; interface InputSliderProps { value: number; setValue: (value: number) => void; step: number; min: number; max: number; label: string; } function InputSlider({ value, setValue, step, min, max, label, }: InputSliderProps) { const handleSliderChange = (event: Event, newValue: number | number[]) => { setValue(newValue as number); }; const handleInputChange = (event: React.ChangeEvent) => { setValue(event.target.value === '' ? 0 : Number(event.target.value)); }; const handleBlur = () => { if (value < min) { setValue(min); } else if (value > max) { setValue(max); } }; return ( {label} ); } interface LineSettingProps { modelList: ModelInfo[]; lines: LineState[]; setLines: (lines: LineState[]) => void; currentIndex: number; } export default function LineSetting({ modelList, lines, setLines, currentIndex, }: LineSettingProps) { const [styleWeightUB, setStyleWeightUB] = useState(10); const setLineState = (newState: Partial) => { const newLines = lines.map((line, index) => { if (index === currentIndex) { return { ...line, ...newState, }; } return line; }); setLines(newLines); }; const handleModelChange = (model: string) => { const selected = modelList?.find((m) => m.name === model); setLineState({ model, modelFile: selected?.files[0] || '', style: selected?.styles[0] || '', speaker: selected?.speakers?.[0] || '', }); }; const handleDefault = () => { setLineState({ ...defaultLineState, model: lines[currentIndex].model, modelFile: lines[currentIndex].modelFile, text: lines[currentIndex].text, speaker: lines[currentIndex].speaker, //もし選択肢にNeutralがあればそれを選択、あるはずだが一応 style: modelList .find((model) => model.name === lines[currentIndex].model) ?.styles.includes('Neutral') ? 'Neutral' : modelList.find((model) => model.name === lines[currentIndex].model) ?.styles[0] || '', }); }; return ( テキスト{currentIndex + 1}の設定 {/* Model Image Display */} {lines[currentIndex].model} { // Hide image if it doesn't exist (e.target as HTMLImageElement).style.display = 'none'; }} /> モデル モデルファイル 話者 スタイル setStyleWeightUB(value)} step={0.1} min={1} max={20} /> setLineState({ styleWeight: value })} step={0.1} min={0} max={styleWeightUB} /> setLineState({ speed: value })} step={0.05} min={0.5} max={2} /> setLineState({ sdpRatio: value })} step={0.05} min={0} max={1} /> setLineState({ noise: value })} step={0.05} min={0} max={1} /> setLineState({ noisew: value })} step={0.05} min={0} max={1} /> setLineState({ pitchScale: value })} step={0.05} min={0.7} max={1.3} /> setLineState({ intonationScale: value })} step={0.05} min={0.7} max={1.3} /> setLineState({ silenceAfter: value })} step={0.05} min={0} max={1.5} /> ); }