Skip to content

Commit

Permalink
ソング:Speakerの初期化時にUIをロックしないようにする (VOICEVOX#2413)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigprogramming authored Dec 15, 2024
1 parent 84bd237 commit 0d08b86
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
3 changes: 2 additions & 1 deletion src/store/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,10 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
audioKeys,
});
await actions
.INITIALIZE_ENGINE_SPEAKER({
.INITIALIZE_ENGINE_CHARACTER({
engineId,
styleId,
uiLock: true,
})
.finally(() => {
mutations.SET_AUDIO_KEYS_WITH_INITIALIZING_SPEAKER({
Expand Down
36 changes: 21 additions & 15 deletions src/store/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,23 +330,29 @@ export const engineStore = createPartialStore<EngineStoreTypes>({
},
},

INITIALIZE_ENGINE_SPEAKER: {
INITIALIZE_ENGINE_CHARACTER: {
/**
* 指定した話者(スタイルID)に対してエンジン側の初期化を行い、即座に音声合成ができるようにする。
* 指定したキャラクター(スタイルID)に対してエンジン側の初期化を行い、即座に音声合成ができるようにする。
*/
async action({ actions }, { engineId, styleId }) {
await actions.ASYNC_UI_LOCK({
callback: () =>
actions
.INSTANTIATE_ENGINE_CONNECTOR({
engineId,
})
.then((instance) =>
instance.invoke("initializeSpeakerInitializeSpeakerPost")({
speaker: styleId,
}),
),
});
async action({ actions }, { engineId, styleId, uiLock }) {
const requestEngineToInitializeCharacter = () =>
actions
.INSTANTIATE_ENGINE_CONNECTOR({
engineId,
})
.then((instance) =>
instance.invoke("initializeSpeakerInitializeSpeakerPost")({
speaker: styleId,
}),
);

if (uiLock) {
await actions.ASYNC_UI_LOCK({
callback: requestEngineToInitializeCharacter,
});
} else {
await requestEngineToInitializeCharacter();
}
},
},
VALIDATE_ENGINE_DIR: {
Expand Down
6 changes: 5 additions & 1 deletion src/store/singing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,11 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
// 指定されたstyleIdに対して、エンジン側の初期化を行う
const isInitialized = await actions.IS_INITIALIZED_ENGINE_SPEAKER(singer);
if (!isInitialized) {
await actions.INITIALIZE_ENGINE_SPEAKER(singer);
await actions.INITIALIZE_ENGINE_CHARACTER({
engineId: singer.engineId,
styleId: singer.styleId,
uiLock: false,
});
}
},
},
Expand Down
8 changes: 6 additions & 2 deletions src/store/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1638,8 +1638,12 @@ export type EngineStoreTypes = {
action(payload: { engineId: EngineId; styleId: StyleId }): Promise<boolean>;
};

INITIALIZE_ENGINE_SPEAKER: {
action(payload: { engineId: EngineId; styleId: StyleId }): void;
INITIALIZE_ENGINE_CHARACTER: {
action(payload: {
engineId: EngineId;
styleId: StyleId;
uiLock: boolean;
}): void;
};

VALIDATE_ENGINE_DIR: {
Expand Down

0 comments on commit 0d08b86

Please sign in to comment.