From 4a07735967e03aaf31e821e5726c3db73c89370d Mon Sep 17 00:00:00 2001 From: aoirint Date: Sat, 19 Mar 2022 21:48:36 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=87=E3=83=95=E3=82=A9=E3=83=AB=E3=83=88?= =?UTF-8?q?=E3=82=B9=E3=82=BF=E3=82=A4=E3=83=AB=E3=83=80=E3=82=A4=E3=82=A2?= =?UTF-8?q?=E3=83=AD=E3=82=B0:=20speakerUuid=E3=81=8C=E7=95=B0=E3=81=AA?= =?UTF-8?q?=E3=82=8B=E5=A0=B4=E5=90=88=E3=81=ABstyleId=E3=81=AE=E9=87=8D?= =?UTF-8?q?=E8=A4=87=E3=82=92=E8=A8=B1=E5=AE=B9=E3=81=99=E3=82=8B=20(#755)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * DefaultStyleSelectDialog: allow duplication of styleId when speakerUuid is different * Update src/components/DefaultStyleSelectDialog.vue Co-authored-by: Hiroshiba --- src/components/DefaultStyleSelectDialog.vue | 24 +++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/components/DefaultStyleSelectDialog.vue b/src/components/DefaultStyleSelectDialog.vue index 75c5fad898..198b1aedaa 100644 --- a/src/components/DefaultStyleSelectDialog.vue +++ b/src/components/DefaultStyleSelectDialog.vue @@ -132,6 +132,8 @@ outline :icon=" playing != undefined && + characterInfo.metas.speakerUuid === + playing.speakerUuid && style.styleId === playing.styleId && voiceSampleIndex === playing.index ? 'stop' @@ -143,6 +145,8 @@ @mouseleave="isHoverableStyleItem = true" @click.stop=" playing != undefined && + characterInfo.metas.speakerUuid === + playing.speakerUuid && style.styleId === playing.styleId && voiceSampleIndex === playing.index ? stop() @@ -265,16 +269,17 @@ export default defineComponent({ const selectStyleIndex = (characterIndex: number, styleIndex: number) => { selectedStyleIndexes.value[characterIndex] = styleIndex; - // 音声を再生する。同じstyleIndexだったら停止する。 - const selectedStyleInfo = - showCharacterInfos.value[characterIndex].metas.styles[styleIndex]; + // 音声を再生する。同じ話者/styleIndexだったら停止する。 + const selectedCharacter = showCharacterInfos.value[characterIndex]; + const selectedStyleInfo = selectedCharacter.metas.styles[styleIndex]; if ( playing.value !== undefined && + playing.value.speakerUuid === selectedCharacter.metas.speakerUuid && playing.value.styleId === selectedStyleInfo.styleId ) { stop(); } else { - play(selectedStyleInfo, 0); + play(selectedCharacter.metas.speakerUuid, selectedStyleInfo, 0); } }; @@ -282,7 +287,8 @@ export default defineComponent({ const isHoverableStyleItem = ref(true); - const playing = ref<{ styleId: number; index: number }>(); + const playing = + ref<{ speakerUuid: string; styleId: number; index: number }>(); const audio = new Audio(); audio.volume = 0.5; @@ -293,12 +299,16 @@ export default defineComponent({ return selectedStyleIndex !== undefined; }); - const play = ({ styleId, voiceSamplePaths }: StyleInfo, index: number) => { + const play = ( + speakerUuid: string, + { styleId, voiceSamplePaths }: StyleInfo, + index: number + ) => { if (audio.src !== "") stop(); audio.src = voiceSamplePaths[index]; audio.play(); - playing.value = { styleId, index }; + playing.value = { speakerUuid, styleId, index }; }; const stop = () => { if (audio.src === "") return;