From 73501e1ada33159caf2aa527e3d69afb73103cec Mon Sep 17 00:00:00 2001 From: Hiroshiba Kazuyuki Date: Sat, 21 Dec 2024 02:13:59 +0900 Subject: [PATCH] a --- src/components/Dialog/PresetManageDialog.vue | 96 +++++--------------- 1 file changed, 25 insertions(+), 71 deletions(-) diff --git a/src/components/Dialog/PresetManageDialog.vue b/src/components/Dialog/PresetManageDialog.vue index e8edfb865b..71cbe7882b 100644 --- a/src/components/Dialog/PresetManageDialog.vue +++ b/src/components/Dialog/PresetManageDialog.vue @@ -60,27 +60,33 @@

{{ selectedPreset.name }}

@@ -153,7 +159,7 @@ import BaseIconButton from "@/components/Base/BaseIconButton.vue"; import BaseSlider from "@/components/Base/BaseSlider.vue"; import CharacterButton from "@/components/CharacterButton.vue"; import { useDefaultPreset } from "@/composables/useDefaultPreset"; -import { Preset, PresetKey } from "@/type/preload"; +import { Preset, PresetKey, PresetSliderKey } from "@/type/preload"; import { SLIDER_PARAMETERS } from "@/store/utility"; const props = defineProps<{ @@ -205,67 +211,15 @@ const selectedPreset = computed(() => { ); }); -const parameterConfigs = [ - { - label: "話速", - parameterKey: "speedScale", - }, - { - label: "音高", - parameterKey: "pitchScale", - }, - { - label: "抑揚", - parameterKey: "intonationScale", - }, - { - label: "音量", - parameterKey: "volumeScale", - }, - { - label: "開始無音", - parameterKey: "prePhonemeLength", - }, - { - label: "終了無音", - parameterKey: "postPhonemeLength", - }, -]; - -const getParameterConfig = (sliderKey: string) => { - switch (sliderKey) { - case "SPEED": - return parameterConfigs[0]; - case "PITCH": - return parameterConfigs[1]; - case "INTONATION": - return parameterConfigs[2]; - case "VOLUME": - return parameterConfigs[3]; - case "PRE_PHONEME_LENGTH": - return parameterConfigs[4]; - case "POST_PHONEME_LENGTH": - return parameterConfigs[5]; - } -}; - -const getParameterValue = (sliderKey: string) => { - if (!selectedPreset.value) { - throw new Error("selectedPreset is undefined"); - } - - const parameters = Object.entries(selectedPreset.value); - const parameter = parameters.find( - (preset) => preset[0] === getParameterConfig(sliderKey)?.parameterKey, - ); - - const parameterValue = Number(parameter?.[1]); - - if (Number.isNaN(parameterValue)) { - return; - } - - return parameterValue; +type ParameterType = Exclude; +const parameterLabels: Record = { + speedScale: "話速", + pitchScale: "音高", + intonationScale: "抑揚", + volumeScale: "音量", + pauseLengthScale: "間の長さ", + prePhonemeLength: "開始無音", + postPhonemeLength: "終了無音", }; const reorderPreset = (featurePresetList: (Preset & { key: PresetKey })[]) => {