From 92bf9ad464dbf776e64ebac5b5b868ce8f871aba Mon Sep 17 00:00:00 2001 From: k-chop Date: Sat, 11 Mar 2023 20:07:45 +0900 Subject: [PATCH 01/16] =?UTF-8?q?audioItem,=20presetItem=E3=82=92=E6=B8=A1?= =?UTF-8?q?=E3=81=97=E3=81=A6audioItem=E3=82=92=E8=BF=94=E3=81=99=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E3=81=AB=E5=88=87=E3=82=8A=E5=87=BA=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/audio.ts | 113 ++++++++++++++++++++++++++------------------- src/store/type.ts | 5 -- 2 files changed, 66 insertions(+), 52 deletions(-) diff --git a/src/store/audio.ts b/src/store/audio.ts index 3faa60e151..92b39c6a1c 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -31,6 +31,7 @@ import { EngineId, MoraDataType, MorphingInfo, + Preset, PresetKey, SpeakerId, StyleId, @@ -253,6 +254,38 @@ export function determineNextPresetKey( }; } +/** + * 与えたAudioItemを元に、Presetを適用した新しいAudioItemを返す + */ +export function applyAudioPresetToAudioItem( + audioItem: AudioItem | undefined, + presetItem: Preset | undefined +) { + if ( + audioItem == undefined || + audioItem.presetKey == undefined || + audioItem.query == undefined + ) + return; + if (presetItem == undefined) return; + + const newAudioItem = { ...audioItem }; + + // Filter name property from presetItem in order to extract audioInfos. + const { name: _, morphingInfo, ...presetAudioInfos } = presetItem; + + // Type Assertion + const audioInfos: Omit< + AudioQuery, + "accentPhrases" | "outputSamplingRate" | "outputStereo" | "kana" + > = presetAudioInfos; + + newAudioItem.query = { ...audioItem.query, ...audioInfos }; + newAudioItem.morphingInfo = morphingInfo; + + return newAudioItem; +} + const audioBlobCache: Record = {}; const audioElements: Record = {}; @@ -603,9 +636,9 @@ export const audioStore = createPartialStore({ }).catch(() => undefined) : undefined; - const audioItem: AudioItem = { text, voice }; + let newAudioItem: AudioItem = { text, voice }; if (query != undefined) { - audioItem.query = query; + newAudioItem.query = query; } const presetKeyCandidate = payload.baseAudioItem?.presetKey; @@ -616,35 +649,44 @@ export const audioStore = createPartialStore({ presetKeyCandidate, state.inheritAudioInfo && baseAudioItem !== undefined ); - audioItem.presetKey = nextPresetKey; + newAudioItem.presetKey = nextPresetKey; if ( state.inheritAudioInfo && baseAudioItem && baseAudioItem.query && - audioItem.query + newAudioItem.query ) { //引数にbaseAudioItemがある場合、話速等のパラメータを引き継いだAudioItemを返す //baseAudioItem.queryが未設定の場合は引き継がない(起動直後等?) - audioItem.query.speedScale = baseAudioItem.query.speedScale; - audioItem.query.pitchScale = baseAudioItem.query.pitchScale; - audioItem.query.intonationScale = baseAudioItem.query.intonationScale; - audioItem.query.volumeScale = baseAudioItem.query.volumeScale; - audioItem.query.prePhonemeLength = baseAudioItem.query.prePhonemeLength; - audioItem.query.postPhonemeLength = + newAudioItem.query.speedScale = baseAudioItem.query.speedScale; + newAudioItem.query.pitchScale = baseAudioItem.query.pitchScale; + newAudioItem.query.intonationScale = + baseAudioItem.query.intonationScale; + newAudioItem.query.volumeScale = baseAudioItem.query.volumeScale; + newAudioItem.query.prePhonemeLength = + baseAudioItem.query.prePhonemeLength; + newAudioItem.query.postPhonemeLength = baseAudioItem.query.postPhonemeLength; - audioItem.query.outputSamplingRate = + newAudioItem.query.outputSamplingRate = baseAudioItem.query.outputSamplingRate; - audioItem.query.outputStereo = baseAudioItem.query.outputStereo; - audioItem.morphingInfo = baseAudioItem.morphingInfo; + newAudioItem.query.outputStereo = baseAudioItem.query.outputStereo; + newAudioItem.morphingInfo = baseAudioItem.morphingInfo; } // audioItemに対してプリセットを適用する if (shouldApplyPreset) { - await dispatch("APPLY_AUDIO_PRESET_TO_AUDIO_ITEM", { audioItem }); + if (nextPresetKey) { + const preset = state.presetItems[nextPresetKey]; + const result = applyAudioPresetToAudioItem(newAudioItem, preset); + + if (result) { + newAudioItem = result; + } + } } - return audioItem; + return newAudioItem; }, }, @@ -1045,41 +1087,18 @@ export const audioStore = createPartialStore({ }, }, - APPLY_AUDIO_PRESET_TO_AUDIO_ITEM: { - // FIXME: audioItemを直接書き換えないようにするか、関数化する - mutation(state, { audioItem }) { - if ( - audioItem == undefined || - audioItem.presetKey == undefined || - audioItem.query == undefined - ) - return; - const presetItem = state.presetItems[audioItem.presetKey]; - if (presetItem == undefined) return; - - // Filter name property from presetItem in order to extract audioInfos. - const { name: _, morphingInfo, ...presetAudioInfos } = presetItem; - - // Type Assertion - const audioInfos: Omit< - AudioQuery, - "accentPhrases" | "outputSamplingRate" | "outputStereo" | "kana" - > = presetAudioInfos; + APPLY_AUDIO_PRESET: { + mutation(state, { audioKey }: { audioKey: AudioKey }) { + const audioItem = state.audioItems[audioKey]; - audioItem.query = { ...audioItem.query, ...audioInfos }; + if (!audioItem || !audioItem.presetKey) return; - audioItem.morphingInfo = morphingInfo; - }, - action({ commit }, { audioItem }) { - commit("APPLY_AUDIO_PRESET_TO_AUDIO_ITEM", { audioItem }); - }, - }, + const presetItem = state.presetItems[audioItem.presetKey]; + const newAudioItem = applyAudioPresetToAudioItem(audioItem, presetItem); - APPLY_AUDIO_PRESET: { - mutation(state, { audioKey }: { audioKey: AudioKey }) { - audioStore.mutations.APPLY_AUDIO_PRESET_TO_AUDIO_ITEM(state, { - audioItem: state.audioItems[audioKey], - }); + if (newAudioItem) { + state.audioItems[audioKey] = newAudioItem; + } }, }, diff --git a/src/store/type.ts b/src/store/type.ts index 88034e8c27..659b26e330 100644 --- a/src/store/type.ts +++ b/src/store/type.ts @@ -359,11 +359,6 @@ export type AudioStoreTypes = { }; }; - APPLY_AUDIO_PRESET_TO_AUDIO_ITEM: { - mutation: { audioItem: AudioItem }; - action(payload: { audioItem: AudioItem }): void; - }; - APPLY_AUDIO_PRESET: { mutation: { audioKey: AudioKey }; }; From 9fdcc6fdc24d3bb35efe5a4efdcc3631846430e7 Mon Sep 17 00:00:00 2001 From: k-chop Date: Sat, 11 Mar 2023 23:51:40 +0900 Subject: [PATCH 02/16] =?UTF-8?q?determineNextPresetKey=E3=81=AE=E5=BC=95?= =?UTF-8?q?=E6=95=B0=E3=82=92=E5=88=86=E3=81=8B=E3=82=8A=E3=82=84=E3=81=99?= =?UTF-8?q?=E3=81=8F=E3=81=97=E3=81=9F=E4=B8=8A=E3=81=A7switch=E6=96=87?= =?UTF-8?q?=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/audio.ts | 116 ++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/src/store/audio.ts b/src/store/audio.ts index 92b39c6a1c..d160849b5a 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -195,8 +195,7 @@ export function determineNextPresetKey( state: State, voice: Voice, presetKeyCandidate: PresetKey | undefined, - shouldCopyBaseAudioItem: boolean, - isVoiceChanged = false + operation: "generate" | "copy" | "changeVoice" ): { nextPresetKey: PresetKey | undefined; shouldApplyPreset: boolean; @@ -204,54 +203,55 @@ export function determineNextPresetKey( const defaultPresetKeyForCurrentVoice = state.defaultPresetKeys[VoiceId(voice)]; - const isDefaultPreset = Object.values(state.defaultPresetKeys).some( - (key) => key === presetKeyCandidate - ); - - // コピーすべきBaseAudioItemがない=初回作成時 - if (!shouldCopyBaseAudioItem) { - return { - nextPresetKey: defaultPresetKeyForCurrentVoice, - shouldApplyPreset: state.experimentalSetting.enablePreset, - }; - } - - // ボイス切り替え時 - if (isVoiceChanged) { - if (state.experimentalSetting.shouldApplyDefaultPresetOnVoiceChanged) { - // デフォルトプリセットを適用する + switch (operation) { + case "generate": { + // 初回作成時 return { nextPresetKey: defaultPresetKeyForCurrentVoice, - shouldApplyPreset: true, + shouldApplyPreset: state.experimentalSetting.enablePreset, }; } + case "copy": { + // 元となるAudioItemがある場合 + if (state.inheritAudioInfo) { + // パラメータ引継ぎがONならそのまま引き継ぐ + return { + nextPresetKey: presetKeyCandidate, + shouldApplyPreset: false, + }; + } - // 引き継ぎ元が他スタイルのデフォルトプリセットだった場合 - // 別キャラのデフォルトプリセットを引き継がないようにする - // それ以外は指定そのまま - return { - nextPresetKey: isDefaultPreset - ? defaultPresetKeyForCurrentVoice - : presetKeyCandidate, - shouldApplyPreset: false, - }; - } + // それ以外はデフォルトプリセットを割り当て、適用するかはプリセットのON/OFFに依存 + return { + nextPresetKey: defaultPresetKeyForCurrentVoice, + shouldApplyPreset: state.experimentalSetting.enablePreset, + }; + } + case "changeVoice": { + // ボイス切り替え時 + if (state.experimentalSetting.shouldApplyDefaultPresetOnVoiceChanged) { + // デフォルトプリセットを適用する + return { + nextPresetKey: defaultPresetKeyForCurrentVoice, + shouldApplyPreset: true, + }; + } - // 以下はAudioItemコピー時 + const isDefaultPreset = Object.values(state.defaultPresetKeys).some( + (key) => key === presetKeyCandidate + ); - if (state.inheritAudioInfo) { - // パラメータ引継ぎがONならそのまま引き継ぐ - return { - nextPresetKey: presetKeyCandidate, - shouldApplyPreset: false, - }; + // 引き継ぎ元が他スタイルのデフォルトプリセットだった場合 + // 別キャラのデフォルトプリセットを引き継がないようにする + // それ以外は指定そのまま + return { + nextPresetKey: isDefaultPreset + ? defaultPresetKeyForCurrentVoice + : presetKeyCandidate, + shouldApplyPreset: false, + }; + } } - - // それ以外はデフォルトプリセットを割り当て、適用するかはプリセットのON/OFFに依存 - return { - nextPresetKey: defaultPresetKeyForCurrentVoice, - shouldApplyPreset: state.experimentalSetting.enablePreset, - }; } /** @@ -636,7 +636,7 @@ export const audioStore = createPartialStore({ }).catch(() => undefined) : undefined; - let newAudioItem: AudioItem = { text, voice }; + const newAudioItem: AudioItem = { text, voice }; if (query != undefined) { newAudioItem.query = query; } @@ -647,10 +647,23 @@ export const audioStore = createPartialStore({ state, voice, presetKeyCandidate, - state.inheritAudioInfo && baseAudioItem !== undefined + baseAudioItem ? "copy" : "generate" ); newAudioItem.presetKey = nextPresetKey; + // audioItemに対してプリセットを適用する + if (shouldApplyPreset) { + if (nextPresetKey) { + const preset = state.presetItems[nextPresetKey]; + const result = applyAudioPresetToAudioItem(newAudioItem, preset); + + if (result) { + return result; + } + } + } + + // プリセットを適用しないならパラメータを引き継ぐ if ( state.inheritAudioInfo && baseAudioItem && @@ -674,18 +687,6 @@ export const audioStore = createPartialStore({ newAudioItem.morphingInfo = baseAudioItem.morphingInfo; } - // audioItemに対してプリセットを適用する - if (shouldApplyPreset) { - if (nextPresetKey) { - const preset = state.presetItems[nextPresetKey]; - const result = applyAudioPresetToAudioItem(newAudioItem, preset); - - if (result) { - newAudioItem = result; - } - } - } - return newAudioItem; }, }, @@ -2139,8 +2140,7 @@ export const audioCommandStore = transformCommandStore( draft, payload.voice, presetKey, - true, - true + "changeVoice" ); audioStore.mutations.SET_AUDIO_PRESET_KEY(draft, { From 429307a4e521327a44f2891fd4f2c201fd8edcd7 Mon Sep 17 00:00:00 2001 From: k-chop Date: Sat, 11 Mar 2023 23:54:05 +0900 Subject: [PATCH 03/16] =?UTF-8?q?=E4=B8=AD=E3=81=A7=E4=BD=BF=E3=81=86?= =?UTF-8?q?=E3=83=97=E3=83=AD=E3=83=91=E3=83=86=E3=82=A3=E3=81=A0=E3=81=91?= =?UTF-8?q?=E3=81=AB=E7=8B=AD=E3=82=81=E3=81=A6=E3=81=8A=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/audio.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/store/audio.ts b/src/store/audio.ts index d160849b5a..6517f72867 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -192,7 +192,10 @@ export function getCharacterInfo( * configを参照して割り当てるべきpresetKeyとそのPresetを適用すべきかどうかを返す */ export function determineNextPresetKey( - state: State, + state: Pick< + State, + "defaultPresetKeys" | "experimentalSetting" | "inheritAudioInfo" + >, voice: Voice, presetKeyCandidate: PresetKey | undefined, operation: "generate" | "copy" | "changeVoice" From a7d1bc65af54ae97abf2771069bdc7ea4067546a Mon Sep 17 00:00:00 2001 From: k-chop Date: Sun, 12 Mar 2023 00:40:00 +0900 Subject: [PATCH 04/16] =?UTF-8?q?defaultPresetKey=E3=81=AEset=E3=82=92gett?= =?UTF-8?q?ers=E3=81=AB=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/composables/useDefaultPreset.ts | 5 +---- src/store/audio.ts | 6 ++++++ src/store/type.ts | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/composables/useDefaultPreset.ts b/src/composables/useDefaultPreset.ts index 4305c6aa5b..5e6043aa9d 100644 --- a/src/composables/useDefaultPreset.ts +++ b/src/composables/useDefaultPreset.ts @@ -6,9 +6,6 @@ export const useDefaultPreset = () => { const store = useStore(); const defaultPresetKeys = computed(() => store.state.defaultPresetKeys); - const defaultPresetKeySets = computed( - () => new Set(Object.values(store.state.defaultPresetKeys)) - ); const getDefaultPresetKeyForVoice = (voice: Voice): string => { const voiceId = VoiceId(voice); @@ -16,7 +13,7 @@ export const useDefaultPreset = () => { }; const isDefaultPresetKey = (presetKey: PresetKey): boolean => { - return defaultPresetKeySets.value.has(presetKey); + return store.getters.DEFAULT_PRESET_KEY_SETS.has(presetKey); }; return { diff --git a/src/store/audio.ts b/src/store/audio.ts index 6517f72867..0f4863b752 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -333,6 +333,12 @@ export const audioStore = createPartialStore({ }, }, + DEFAULT_PRESET_KEY_SETS: { + getter: (state) => { + return new Set(Object.values(state.defaultPresetKeys)); + }, + }, + LOAD_CHARACTER: { action: createUILockAction(async ({ commit, dispatch }, { engineId }) => { const speakers = await dispatch("INSTANTIATE_ENGINE_CONNECTOR", { diff --git a/src/store/type.ts b/src/store/type.ts index 659b26e330..1b716475b0 100644 --- a/src/store/type.ts +++ b/src/store/type.ts @@ -144,6 +144,10 @@ export type AudioStoreTypes = { getter: number | undefined; }; + DEFAULT_PRESET_KEY_SETS: { + getter: Set; + }; + LOAD_CHARACTER: { action(payload: { engineId: EngineId }): void; }; From 44689624a0da42e7fdbb387d534681cf52adfe27 Mon Sep 17 00:00:00 2001 From: k-chop Date: Sun, 12 Mar 2023 00:47:54 +0900 Subject: [PATCH 05/16] =?UTF-8?q?export=E3=81=97=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=81=A7=E3=81=8A=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/audio.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/audio.ts b/src/store/audio.ts index 0f4863b752..b46f1f5754 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -191,7 +191,7 @@ export function getCharacterInfo( /** * configを参照して割り当てるべきpresetKeyとそのPresetを適用すべきかどうかを返す */ -export function determineNextPresetKey( +function determineNextPresetKey( state: Pick< State, "defaultPresetKeys" | "experimentalSetting" | "inheritAudioInfo" From fb2023e49592f5e8cd88602ddcb7e7f30172415b Mon Sep 17 00:00:00 2001 From: k-chop Date: Sat, 1 Apr 2023 13:12:11 +0900 Subject: [PATCH 06/16] =?UTF-8?q?determineNextPresetKey=E3=82=92preset.ts?= =?UTF-8?q?=E3=81=AB=E7=A7=BB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/audio.ts | 71 +------------------------------------------ src/store/preset.ts | 73 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/src/store/audio.ts b/src/store/audio.ts index b46f1f5754..22d7cafa75 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -23,6 +23,7 @@ import { } from "./utility"; import { convertAudioQueryFromEditorToEngine } from "./proxy"; import { createPartialStore } from "./vuex"; +import { determineNextPresetKey } from "./preset"; import { AudioKey, CharacterInfo, @@ -37,7 +38,6 @@ import { StyleId, StyleInfo, Voice, - VoiceId, WriteFileErrorResult, } from "@/type/preload"; import { AudioQuery, AccentPhrase, Speaker, SpeakerInfo } from "@/openapi"; @@ -188,75 +188,6 @@ export function getCharacterInfo( ); } -/** - * configを参照して割り当てるべきpresetKeyとそのPresetを適用すべきかどうかを返す - */ -function determineNextPresetKey( - state: Pick< - State, - "defaultPresetKeys" | "experimentalSetting" | "inheritAudioInfo" - >, - voice: Voice, - presetKeyCandidate: PresetKey | undefined, - operation: "generate" | "copy" | "changeVoice" -): { - nextPresetKey: PresetKey | undefined; - shouldApplyPreset: boolean; -} { - const defaultPresetKeyForCurrentVoice = - state.defaultPresetKeys[VoiceId(voice)]; - - switch (operation) { - case "generate": { - // 初回作成時 - return { - nextPresetKey: defaultPresetKeyForCurrentVoice, - shouldApplyPreset: state.experimentalSetting.enablePreset, - }; - } - case "copy": { - // 元となるAudioItemがある場合 - if (state.inheritAudioInfo) { - // パラメータ引継ぎがONならそのまま引き継ぐ - return { - nextPresetKey: presetKeyCandidate, - shouldApplyPreset: false, - }; - } - - // それ以外はデフォルトプリセットを割り当て、適用するかはプリセットのON/OFFに依存 - return { - nextPresetKey: defaultPresetKeyForCurrentVoice, - shouldApplyPreset: state.experimentalSetting.enablePreset, - }; - } - case "changeVoice": { - // ボイス切り替え時 - if (state.experimentalSetting.shouldApplyDefaultPresetOnVoiceChanged) { - // デフォルトプリセットを適用する - return { - nextPresetKey: defaultPresetKeyForCurrentVoice, - shouldApplyPreset: true, - }; - } - - const isDefaultPreset = Object.values(state.defaultPresetKeys).some( - (key) => key === presetKeyCandidate - ); - - // 引き継ぎ元が他スタイルのデフォルトプリセットだった場合 - // 別キャラのデフォルトプリセットを引き継がないようにする - // それ以外は指定そのまま - return { - nextPresetKey: isDefaultPreset - ? defaultPresetKeyForCurrentVoice - : presetKeyCandidate, - shouldApplyPreset: false, - }; - } - } -} - /** * 与えたAudioItemを元に、Presetを適用した新しいAudioItemを返す */ diff --git a/src/store/preset.ts b/src/store/preset.ts index e162c6248f..13922e5767 100644 --- a/src/store/preset.ts +++ b/src/store/preset.ts @@ -1,7 +1,76 @@ import { v4 as uuidv4 } from "uuid"; import { createPartialStore } from "./vuex"; -import { PresetStoreState, PresetStoreTypes } from "@/store/type"; -import { Preset, PresetKey, VoiceId } from "@/type/preload"; +import { PresetStoreState, PresetStoreTypes, State } from "@/store/type"; +import { Preset, PresetKey, Voice, VoiceId } from "@/type/preload"; + +/** + * configを参照して割り当てるべきpresetKeyとそのPresetを適用すべきかどうかを返す + */ +export function determineNextPresetKey( + state: Pick< + State, + "defaultPresetKeys" | "experimentalSetting" | "inheritAudioInfo" + >, + voice: Voice, + presetKeyCandidate: PresetKey | undefined, + operation: "generate" | "copy" | "changeVoice" +): { + nextPresetKey: PresetKey | undefined; + shouldApplyPreset: boolean; +} { + const defaultPresetKeyForCurrentVoice = + state.defaultPresetKeys[VoiceId(voice)]; + + switch (operation) { + case "generate": { + // 初回作成時 + return { + nextPresetKey: defaultPresetKeyForCurrentVoice, + shouldApplyPreset: state.experimentalSetting.enablePreset, + }; + } + case "copy": { + // 元となるAudioItemがある場合 + if (state.inheritAudioInfo) { + // パラメータ引継ぎがONならそのまま引き継ぐ + return { + nextPresetKey: presetKeyCandidate, + shouldApplyPreset: false, + }; + } + + // それ以外はデフォルトプリセットを割り当て、適用するかはプリセットのON/OFFに依存 + return { + nextPresetKey: defaultPresetKeyForCurrentVoice, + shouldApplyPreset: state.experimentalSetting.enablePreset, + }; + } + case "changeVoice": { + // ボイス切り替え時 + if (state.experimentalSetting.shouldApplyDefaultPresetOnVoiceChanged) { + // デフォルトプリセットを適用する + return { + nextPresetKey: defaultPresetKeyForCurrentVoice, + shouldApplyPreset: true, + }; + } + + const isDefaultPreset = Object.values(state.defaultPresetKeys).some( + (key) => key === presetKeyCandidate + ); + + // 引き継ぎ元が他スタイルのデフォルトプリセットだった場合 + // 別キャラのデフォルトプリセットを引き継がないようにする + // それ以外は指定そのまま + return { + nextPresetKey: isDefaultPreset + ? defaultPresetKeyForCurrentVoice + : presetKeyCandidate, + shouldApplyPreset: false, + }; + } + } +} export const presetStoreState: PresetStoreState = { presetItems: {}, From fad2e12adb8658c59fe37ceaf87b218a3aca84b6 Mon Sep 17 00:00:00 2001 From: k-chop Date: Sat, 1 Apr 2023 13:16:28 +0900 Subject: [PATCH 07/16] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E8=BF=BD=E8=A8=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/preset.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/store/preset.ts b/src/store/preset.ts index 13922e5767..018252cbeb 100644 --- a/src/store/preset.ts +++ b/src/store/preset.ts @@ -5,6 +5,10 @@ import { Preset, PresetKey, Voice, VoiceId } from "@/type/preload"; /** * configを参照して割り当てるべきpresetKeyとそのPresetを適用すべきかどうかを返す + * + * generate: プロジェクト新規作成時、空のAudioItemを作成する場合 + * copy: 元となるAudioItemがある場合(+ボタンで作成したとき) + * changeVoice: ボイス切り替え時 */ export function determineNextPresetKey( state: Pick< From 15f2b7d183374c3adcda834fd583923ffd523a06 Mon Sep 17 00:00:00 2001 From: k-chop Date: Tue, 4 Apr 2023 00:03:57 +0900 Subject: [PATCH 08/16] =?UTF-8?q?DEFAULT=5FPRESET=5FKEYS=E3=82=92preset=20?= =?UTF-8?q?store=E3=81=B8=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/audio.ts | 6 ------ src/store/preset.ts | 6 ++++++ src/store/type.ts | 7 +++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/store/audio.ts b/src/store/audio.ts index 22d7cafa75..e4fc42c1f9 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -264,12 +264,6 @@ export const audioStore = createPartialStore({ }, }, - DEFAULT_PRESET_KEY_SETS: { - getter: (state) => { - return new Set(Object.values(state.defaultPresetKeys)); - }, - }, - LOAD_CHARACTER: { action: createUILockAction(async ({ commit, dispatch }, { engineId }) => { const speakers = await dispatch("INSTANTIATE_ENGINE_CONNECTOR", { diff --git a/src/store/preset.ts b/src/store/preset.ts index 018252cbeb..8acdec0962 100644 --- a/src/store/preset.ts +++ b/src/store/preset.ts @@ -83,6 +83,12 @@ export const presetStoreState: PresetStoreState = { }; export const presetStore = createPartialStore({ + DEFAULT_PRESET_KEY_SETS: { + getter: (state) => { + return new Set(Object.values(state.defaultPresetKeys)); + }, + }, + SET_PRESET_ITEMS: { mutation( state, diff --git a/src/store/type.ts b/src/store/type.ts index 1b716475b0..e3252d8090 100644 --- a/src/store/type.ts +++ b/src/store/type.ts @@ -144,10 +144,6 @@ export type AudioStoreTypes = { getter: number | undefined; }; - DEFAULT_PRESET_KEY_SETS: { - getter: Set; - }; - LOAD_CHARACTER: { action(payload: { engineId: EngineId }): void; }; @@ -1262,6 +1258,9 @@ export type PresetStoreState = { }; export type PresetStoreTypes = { + DEFAULT_PRESET_KEY_SETS: { + getter: Set; + }; SET_PRESET_ITEMS: { mutation: { presetItems: Record; From 8da40bccd9969b5659d1a351d0d9b80d0e5a7d11 Mon Sep 17 00:00:00 2001 From: kchop Date: Tue, 4 Apr 2023 00:39:04 +0900 Subject: [PATCH 09/16] Update src/store/audio.ts Co-authored-by: Hiroshiba --- src/store/audio.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/store/audio.ts b/src/store/audio.ts index 22d7cafa75..466ac47c03 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -624,7 +624,9 @@ export const audioStore = createPartialStore({ newAudioItem.query.outputSamplingRate = baseAudioItem.query.outputSamplingRate; newAudioItem.query.outputStereo = baseAudioItem.query.outputStereo; - newAudioItem.morphingInfo = baseAudioItem.morphingInfo; + newAudioItem.morphingInfo = baseAudioItem.morphingInfo + ? { ...baseAudioItem.morphingInfo } + : undefined; } return newAudioItem; From 66c208c0f55a13273ab0294f60db21f54a192f24 Mon Sep 17 00:00:00 2001 From: kchop Date: Wed, 5 Apr 2023 23:14:34 +0900 Subject: [PATCH 10/16] Update src/store/audio.ts Co-authored-by: Hiroshiba --- src/store/audio.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/store/audio.ts b/src/store/audio.ts index 65d97dc3ce..3e6475ca3b 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -192,15 +192,12 @@ export function getCharacterInfo( * 与えたAudioItemを元に、Presetを適用した新しいAudioItemを返す */ export function applyAudioPresetToAudioItem( - audioItem: AudioItem | undefined, - presetItem: Preset | undefined + audioItem: AudioItem, + presetItem: Preset ) { - if ( - audioItem == undefined || - audioItem.presetKey == undefined || - audioItem.query == undefined - ) - return; + if (audioItem.query == undefined) { + throw new Error("audioItem.query is undefined"); + } if (presetItem == undefined) return; const newAudioItem = { ...audioItem }; From 298a8b6296a96155ca6ea47567bf33e3f75dee87 Mon Sep 17 00:00:00 2001 From: k-chop Date: Wed, 5 Apr 2023 23:15:51 +0900 Subject: [PATCH 11/16] =?UTF-8?q?presetItem=E3=82=82undefined=E3=83=81?= =?UTF-8?q?=E3=82=A7=E3=83=83=E3=82=AF=E3=81=AF=E4=B8=8D=E8=A6=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/audio.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/store/audio.ts b/src/store/audio.ts index 3e6475ca3b..6ecb66250d 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -198,7 +198,6 @@ export function applyAudioPresetToAudioItem( if (audioItem.query == undefined) { throw new Error("audioItem.query is undefined"); } - if (presetItem == undefined) return; const newAudioItem = { ...audioItem }; From d22eac041025f794a26fedf760bd0b15f47c87de Mon Sep 17 00:00:00 2001 From: k-chop Date: Wed, 5 Apr 2023 23:18:31 +0900 Subject: [PATCH 12/16] =?UTF-8?q?=E5=AE=9A=E7=BE=A9=E7=AE=87=E6=89=80?= =?UTF-8?q?=E3=81=8C=E9=9B=A2=E3=82=8C=E3=81=A6=E3=81=84=E3=81=A6=E8=AA=A4?= =?UTF-8?q?=E8=A7=A3=E3=82=92=E7=94=9F=E3=82=93=E3=81=A0=E3=81=AE=E3=81=A7?= =?UTF-8?q?=E8=BF=91=E3=81=A5=E3=81=91=E3=81=A6=E3=81=8A=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/audio.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/store/audio.ts b/src/store/audio.ts index 6ecb66250d..10c0bf21e0 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -199,8 +199,6 @@ export function applyAudioPresetToAudioItem( throw new Error("audioItem.query is undefined"); } - const newAudioItem = { ...audioItem }; - // Filter name property from presetItem in order to extract audioInfos. const { name: _, morphingInfo, ...presetAudioInfos } = presetItem; @@ -210,6 +208,7 @@ export function applyAudioPresetToAudioItem( "accentPhrases" | "outputSamplingRate" | "outputStereo" | "kana" > = presetAudioInfos; + const newAudioItem = { ...audioItem }; newAudioItem.query = { ...audioItem.query, ...audioInfos }; newAudioItem.morphingInfo = morphingInfo; From 65340e31ef88f4431bc6cc1d6991387a29955ec0 Mon Sep 17 00:00:00 2001 From: k-chop Date: Wed, 5 Apr 2023 23:22:58 +0900 Subject: [PATCH 13/16] =?UTF-8?q?=E8=BF=94=E3=82=8A=E5=80=A4=E3=82=92?= =?UTF-8?q?=E6=98=8E=E7=A4=BA=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/audio.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/audio.ts b/src/store/audio.ts index 10c0bf21e0..d3133152a2 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -194,7 +194,7 @@ export function getCharacterInfo( export function applyAudioPresetToAudioItem( audioItem: AudioItem, presetItem: Preset -) { +): AudioItem { if (audioItem.query == undefined) { throw new Error("audioItem.query is undefined"); } From ce24151350e86380f1fad9e0bc7b10dfdccc0329 Mon Sep 17 00:00:00 2001 From: k-chop Date: Wed, 5 Apr 2023 23:23:45 +0900 Subject: [PATCH 14/16] =?UTF-8?q?=E8=BF=94=E3=82=8A=E5=80=A4=E3=81=AEnull?= =?UTF-8?q?=20check=E3=81=8C=E4=B8=8D=E8=A6=81=E3=81=AB=E3=81=AA=E3=81=A3?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/audio.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/store/audio.ts b/src/store/audio.ts index d3133152a2..e92bea3abe 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -584,11 +584,7 @@ export const audioStore = createPartialStore({ if (shouldApplyPreset) { if (nextPresetKey) { const preset = state.presetItems[nextPresetKey]; - const result = applyAudioPresetToAudioItem(newAudioItem, preset); - - if (result) { - return result; - } + return applyAudioPresetToAudioItem(newAudioItem, preset); } } @@ -1028,9 +1024,7 @@ export const audioStore = createPartialStore({ const presetItem = state.presetItems[audioItem.presetKey]; const newAudioItem = applyAudioPresetToAudioItem(audioItem, presetItem); - if (newAudioItem) { - state.audioItems[audioKey] = newAudioItem; - } + state.audioItems[audioKey] = newAudioItem; }, }, From e875c10e11256a06e1f48c8084f1f19122db3f27 Mon Sep 17 00:00:00 2001 From: k-chop Date: Wed, 5 Apr 2023 23:40:39 +0900 Subject: [PATCH 15/16] =?UTF-8?q?morphingInfo=E3=81=AE=E9=81=A9=E7=94=A8?= =?UTF-8?q?=E6=99=82=E3=82=82copy=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/audio.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/audio.ts b/src/store/audio.ts index e92bea3abe..cb55223ede 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -210,7 +210,7 @@ export function applyAudioPresetToAudioItem( const newAudioItem = { ...audioItem }; newAudioItem.query = { ...audioItem.query, ...audioInfos }; - newAudioItem.morphingInfo = morphingInfo; + newAudioItem.morphingInfo = morphingInfo ? { ...morphingInfo } : undefined; return newAudioItem; } From a5d67a5d4faef3efd15fc76439028311bec3c9e3 Mon Sep 17 00:00:00 2001 From: kchop Date: Sat, 8 Apr 2023 10:30:37 +0900 Subject: [PATCH 16/16] Update src/store/audio.ts Co-authored-by: Hiroshiba --- src/store/audio.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/audio.ts b/src/store/audio.ts index cb55223ede..99c482a53a 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -1019,7 +1019,7 @@ export const audioStore = createPartialStore({ mutation(state, { audioKey }: { audioKey: AudioKey }) { const audioItem = state.audioItems[audioKey]; - if (!audioItem || !audioItem.presetKey) return; + if (!audioItem.presetKey) return; const presetItem = state.presetItems[audioItem.presetKey]; const newAudioItem = applyAudioPresetToAudioItem(audioItem, presetItem);