Skip to content

Commit

Permalink
デフォルトスタイルダイアログ: speakerUuidが異なる場合にstyleIdの重複を許容する (#755)
Browse files Browse the repository at this point in the history
* DefaultStyleSelectDialog: allow duplication of styleId when speakerUuid is different

* Update src/components/DefaultStyleSelectDialog.vue

Co-authored-by: Hiroshiba <hihokaruta@gmail.com>
  • Loading branch information
aoirint and Hiroshiba authored Mar 19, 2022
1 parent bd982ce commit 4a07735
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/components/DefaultStyleSelectDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@
outline
:icon="
playing != undefined &&
characterInfo.metas.speakerUuid ===
playing.speakerUuid &&
style.styleId === playing.styleId &&
voiceSampleIndex === playing.index
? 'stop'
Expand All @@ -143,6 +145,8 @@
@mouseleave="isHoverableStyleItem = true"
@click.stop="
playing != undefined &&
characterInfo.metas.speakerUuid ===
playing.speakerUuid &&
style.styleId === playing.styleId &&
voiceSampleIndex === playing.index
? stop()
Expand Down Expand Up @@ -265,24 +269,26 @@ 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);
}
};
const pageIndex = ref(0);
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;
Expand All @@ -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;
Expand Down

0 comments on commit 4a07735

Please sign in to comment.