Skip to content

Commit

Permalink
モーフィング機能の制限に対応(改) (VOICEVOX#1145)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshiba authored Jan 25, 2023
1 parent 66d7cb5 commit d053d98
Show file tree
Hide file tree
Showing 32 changed files with 589 additions and 44 deletions.
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

0 comments on commit d053d98

Please sign in to comment.