Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

モーフィング機能の制限に対応(改) #1145

Merged
merged 13 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openapi.json

Large diffs are not rendered by default.

86 changes: 71 additions & 15 deletions src/components/AudioInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@
非対応エンジンです
</div>
<div
v-else-if="isValidMorphingInfo"
v-else-if="morphingTargetVoice && !isValidMorphingInfo"
class="text-warning"
style="font-size: 0.7rem"
>
Expand Down Expand Up @@ -482,11 +482,11 @@
</template>

<script setup lang="ts">
import { computed, ref } from "vue";
import { computed, ref, watchEffect } from "vue";
import { QSelectProps } from "quasar";
import { useStore } from "@/store";

import { MorphingInfo, Preset, Voice } from "@/type/preload";
import { CharacterInfo, MorphingInfo, Preset, Voice } from "@/type/preload";
import { previewSliderHelper } from "@/helpers/previewSliderHelper";
import CharacterButton from "./CharacterButton.vue";
import PresetManageDialog from "./PresetManageDialog.vue";
Expand Down Expand Up @@ -644,24 +644,80 @@ const isSupportedMorphing = computed(
() => supportedFeatures.value?.synthesisMorphing
);

const isValidMorphingInfo = computed(() => {
if (audioItem.value.morphingInfo == undefined) return false;
return !store.getters.VALID_MORPHING_INFO(audioItem.value);
});
const isValidMorphingInfo = computed(() =>
store.getters.VALID_MORPHING_INFO(audioItem.value)
);

const morphingTargetEngines = store.getters.MORPHING_SUPPORTED_ENGINES;

const morphingTargetCharacters = computed(() => {
const allCharacters = store.getters.GET_ORDERED_ALL_CHARACTER_INFOS;
return allCharacters
// モーフィング可能なターゲット一覧を取得
watchEffect(() => {
if (
audioItem.value != undefined &&
audioItem.value.engineId != undefined &&
audioItem.value.styleId != undefined
) {
store.dispatch("LOAD_MORPHABLE_TARGETS", {
engineId: audioItem.value.engineId,
baseStyleId: audioItem.value.styleId,
});
}
});

const morphingTargetCharacters = computed<CharacterInfo[]>(() => {
const allCharacterInfos = store.getters.USER_ORDERED_CHARACTER_INFOS;
if (allCharacterInfos == undefined)
throw new Error("USER_ORDERED_CHARACTER_INFOS == undefined");

const baseEngineId = audioItem.value.engineId;
const baseStyleId = audioItem.value.styleId;
if (baseEngineId === undefined || baseStyleId == undefined) {
throw new Error("baseEngineId == undefined || baseStyleId == undefined");
}

// モーフィング対象リストを問い合わせていないときはとりあえず空欄を表示
// FIXME: そもそもモーフィングUIを表示しないようにする
const morphableTargets =
store.state.morphableTargetsInfo[baseEngineId]?.[baseStyleId] ?? {};

const morphableStyleIds = Object.entries(morphableTargets) // FIXME: Voiceにするべき
.filter(([, value]) => value.isMorphable)
.map(([styleId]) => parseInt(styleId));

const characterInfos: CharacterInfo[] = allCharacterInfos
// モーフィング可能なスタイルのみを残す
.map((character) => {
const targetStyles = character.metas.styles.filter((style) =>
morphingTargetEngines.includes(style.engineId)
const styles = character.metas.styles.filter(
(style) =>
morphableStyleIds.includes(style.styleId) &&
style.engineId == baseEngineId
);
character.metas.styles = targetStyles;
return character;
return {
...character,
metas: {
...character.metas,
styles,
},
};
})
// スタイルが1つもないキャラクターは省く
.filter((characters) => characters.metas.styles.length >= 1);

// 選択中のキャラがいない場合は一番上に追加する
if (
morphingTargetVoice.value != undefined &&
!characterInfos.some(
(info) => info.metas.speakerUuid == morphingTargetVoice.value?.speakerId
)
) {
const info = allCharacterInfos.find(
(info) => info.metas.speakerUuid == morphingTargetVoice.value?.speakerId
);
if (info == undefined) throw new Error("info == undefined");
characterInfos.unshift(info);
}

return characterInfos;
});

const morphingTargetVoice = computed({
Expand Down Expand Up @@ -692,7 +748,7 @@ const morphingTargetVoice = computed({
});

const morphingTargetCharacterInfo = computed(() =>
morphingTargetCharacters.value.find(
store.getters.USER_ORDERED_CHARACTER_INFOS?.find(
(character) =>
character.metas.speakerUuid === morphingTargetVoice.value?.speakerId
)
Expand Down
3 changes: 3 additions & 0 deletions src/openapi/.openapi-generator/FILES

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading