Skip to content

Commit

Permalink
ADD: AudioItemにSpeakerIdを追加 (#1092)
Browse files Browse the repository at this point in the history
Co-authored-by: Hiroshiba <[email protected]>
  • Loading branch information
sabonerune and Hiroshiba authored Feb 6, 2023
1 parent b5ac4f7 commit a22046c
Show file tree
Hide file tree
Showing 10 changed files with 202 additions and 263 deletions.
21 changes: 4 additions & 17 deletions src/components/AudioCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,9 @@ const uiLocked = computed(() => store.getters.UI_LOCKED);
const selectedVoice = computed<Voice | undefined>({
get() {
const engineId = audioItem.value.engineId;
const styleId = audioItem.value.styleId;
const { engineId, styleId } = audioItem.value.voice;
if (
engineId == undefined ||
styleId == undefined ||
!store.state.engineIds.some((storeEngineId) => storeEngineId === engineId)
)
return undefined;
Expand All @@ -110,10 +107,9 @@ const selectedVoice = computed<Voice | undefined>({
},
set(voice: Voice | undefined) {
if (voice == undefined) return;
store.dispatch("COMMAND_CHANGE_STYLE_ID", {
store.dispatch("COMMAND_CHANGE_VOICE", {
audioKey: props.audioKey,
engineId: voice.engineId,
styleId: voice.styleId,
voice,
});
},
});
Expand Down Expand Up @@ -179,18 +175,9 @@ const pasteOnAudioCell = async (event: ClipboardEvent) => {
await pushAudioText();
}
const engineId = audioItem.value.engineId;
if (engineId === undefined)
throw new Error("assert engineId !== undefined");
const styleId = audioItem.value.styleId;
if (styleId === undefined)
throw new Error("assert styleId !== undefined");
const audioKeys = await store.dispatch("COMMAND_PUT_TEXTS", {
texts,
engineId,
styleId,
voice: audioItem.value.voice,
prevAudioKey,
});
if (audioKeys)
Expand Down
8 changes: 5 additions & 3 deletions src/components/AudioDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,11 @@ const $q = useQuasar();
const supportedFeatures = computed(
() =>
(audioItem.value?.engineId &&
store.state.engineIds.some((id) => id === audioItem.value.engineId) &&
store.state.engineManifests[audioItem.value?.engineId]
(audioItem.value?.voice.engineId &&
store.state.engineIds.some(
(id) => id === audioItem.value.voice.engineId
) &&
store.state.engineManifests[audioItem.value.voice.engineId]
.supportedFeatures) as EngineManifest["supportedFeatures"] | undefined
);
Expand Down
24 changes: 9 additions & 15 deletions src/components/AudioInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,10 @@ const query = computed(() => audioItem.value?.query);
const supportedFeatures = computed(
() =>
(audioItem.value?.engineId &&
store.state.engineIds.some((id) => id === audioItem.value.engineId) &&
store.state.engineManifests[audioItem.value?.engineId]
(store.state.engineIds.some(
(id) => id === audioItem.value.voice.engineId
) &&
store.state.engineManifests[audioItem.value.voice.engineId]
.supportedFeatures) as EngineManifest["supportedFeatures"] | undefined
);
Expand Down Expand Up @@ -652,14 +653,10 @@ const morphingTargetEngines = store.getters.MORPHING_SUPPORTED_ENGINES;
// モーフィング可能なターゲット一覧を取得
watchEffect(() => {
if (
audioItem.value != undefined &&
audioItem.value.engineId != undefined &&
audioItem.value.styleId != undefined
) {
if (audioItem.value != undefined) {
store.dispatch("LOAD_MORPHABLE_TARGETS", {
engineId: audioItem.value.engineId,
baseStyleId: audioItem.value.styleId,
engineId: audioItem.value.voice.engineId,
baseStyleId: audioItem.value.voice.styleId,
});
}
});
Expand All @@ -669,11 +666,8 @@ const morphingTargetCharacters = computed<CharacterInfo[]>(() => {
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");
}
const baseEngineId = audioItem.value.voice.engineId;
const baseStyleId = audioItem.value.voice.styleId;
// モーフィング対象リストを問い合わせていないときはとりあえず空欄を表示
// FIXME: そもそもモーフィングUIを表示しないようにする
Expand Down
8 changes: 4 additions & 4 deletions src/components/CharacterPortrait.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export default defineComponent({
? store.state.audioItems[activeAudioKey]
: undefined;
const engineId = audioItem?.engineId;
const styleId = audioItem?.styleId;
const engineId = audioItem?.voice.engineId;
const styleId = audioItem?.voice.styleId;
if (
engineId === undefined ||
Expand All @@ -47,7 +47,7 @@ export default defineComponent({
? store.state.audioItems[activeAudioKey]
: undefined;
const styleId = audioItem?.styleId;
const styleId = audioItem?.voice.styleId;
const style = characterInfo.value?.metas.styles.find(
(style) => style.styleId === styleId
);
Expand All @@ -65,7 +65,7 @@ export default defineComponent({
const audioItem = activeAudioKey
? store.state.audioItems[activeAudioKey]
: undefined;
const engineId = audioItem?.engineId ?? store.state.engineIds[0];
const engineId = audioItem?.voice.engineId ?? store.state.engineIds[0];
const engineManifest = store.state.engineManifests[engineId];
const engineInfo = store.state.engineInfos[engineId];
return engineManifest ? engineManifest.brandName : engineInfo.name;
Expand Down
31 changes: 12 additions & 19 deletions src/components/DictionaryManageDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -360,16 +360,15 @@ const selectedId = ref("");
const surface = ref("");
const yomi = ref("");
const styleId = computed(() => {
if (!store.getters.USER_ORDERED_CHARACTER_INFOS) return 0;
return store.getters.USER_ORDERED_CHARACTER_INFOS[0].metas.styles[0].styleId;
});
const engineIdComputed = computed(() => {
const voiceComputed = computed(() => {
if (store.getters.USER_ORDERED_CHARACTER_INFOS == undefined)
throw new Error("assert USER_ORDERED_CHARACTER_INFOS");
if (store.state.engineIds.length === 0)
throw new Error("assert engineId.length > 0");
if (!store.getters.USER_ORDERED_CHARACTER_INFOS)
throw new Error("assert USER_ORDERED_CHARACTER_INFOS");
return store.getters.USER_ORDERED_CHARACTER_INFOS[0].metas.styles[0].engineId;
const characterInfo = store.getters.USER_ORDERED_CHARACTER_INFOS[0].metas;
const speakerId = characterInfo.speakerUuid;
const { engineId, styleId } = characterInfo.styles[0];
return { engineId, speakerId, styleId };
});
const kanaRegex = createKanaRegex();
Expand All @@ -393,8 +392,7 @@ const setSurface = (text: string) => {
surface.value = convertHankakuToZenkaku(text);
};
const setYomi = async (text: string, changeWord?: boolean) => {
const engineId = engineIdComputed.value;
if (engineId === undefined) throw new Error(`assert engineId !== undefined`);
const { engineId, styleId } = voiceComputed.value;
// テキスト長が0の時にエラー表示にならないように、テキスト長を考慮する
isOnlyHiraOrKana.value = !text.length || kanaRegex.test(text);
Expand All @@ -419,7 +417,7 @@ const setYomi = async (text: string, changeWord?: boolean) => {
store.dispatch("FETCH_ACCENT_PHRASES", {
text: text + "ガ'",
engineId,
styleId: styleId.value,
styleId,
isKana: true,
})
)
Expand All @@ -434,8 +432,7 @@ const setYomi = async (text: string, changeWord?: boolean) => {
};
const changeAccent = async (_: number, accent: number) => {
const engineId = engineIdComputed.value;
if (engineId === undefined) throw new Error(`assert engineId !== undefined`);
const { engineId, styleId } = voiceComputed.value;
if (accentPhrase.value) {
accentPhrase.value.accent = accent;
Expand All @@ -444,7 +441,7 @@ const changeAccent = async (_: number, accent: number) => {
store.dispatch("FETCH_MORA_DATA", {
accentPhrases: [accentPhrase.value],
engineId,
styleId: styleId.value,
styleId,
})
)
)[0];
Expand All @@ -455,16 +452,12 @@ const audioElem = new Audio();
audioElem.pause();
const play = async () => {
const engineId = engineIdComputed.value;
if (engineId === undefined) throw new Error(`assert engineId !== undefined`);
if (!accentPhrase.value) return;
nowGenerating.value = true;
const audioItem = await store.dispatch("GENERATE_AUDIO_ITEM", {
text: yomi.value,
engineId,
styleId: styleId.value,
voice: voiceComputed.value,
});
if (audioItem.query == undefined)
Expand Down
Loading

0 comments on commit a22046c

Please sign in to comment.