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

デフォルトスタイルダイアログ: speakerUuidが異なる場合にstyleIdの重複を許容する #755

Merged
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
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