From a35afc6c40f19e6be062c4419f58bd2a9aa60f49 Mon Sep 17 00:00:00 2001 From: sabonerune <102559104+sabonerune@users.noreply.github.com> Date: Thu, 1 Dec 2022 18:31:33 +0900 Subject: [PATCH] =?UTF-8?q?ENH:=20audioStore=E3=81=AB=E3=83=A2=E3=83=BC?= =?UTF-8?q?=E3=83=95=E3=82=A3=E3=83=B3=E3=82=B0=E9=81=A9=E7=94=A8=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=81=9F=E3=82=81=E3=81=AE=E6=93=8D=E4=BD=9C=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/audio.ts | 66 ++++++++++++++++++++++++++++++++++++++++++--- src/store/type.ts | 17 ++++++++++++ src/type/preload.ts | 9 +++++++ 3 files changed, 88 insertions(+), 4 deletions(-) diff --git a/src/store/audio.ts b/src/store/audio.ts index 480abba69a..781f2f28ca 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -18,6 +18,7 @@ import { DefaultStyleId, Encoding as EncodingType, MoraDataType, + MorphingInfo, StyleInfo, WriteFileErrorResult, } from "@/type/preload"; @@ -51,6 +52,7 @@ async function generateUniqueIdAndQuery( audioQuery, audioItem.engineId, audioItem.styleId, + audioItem.morphingInfo, state.experimentalSetting.enableInterrogativeUpspeak, // このフラグが違うと、同じAudioQueryで違う音声が生成されるので追加 ]) ); @@ -477,6 +479,12 @@ export const audioStore = createPartialStore({ baseAudioItem.query.outputSamplingRate; audioItem.query.outputStereo = baseAudioItem.query.outputStereo; } + if ( + baseAudioItem && + audioItem.engineId === baseAudioItem.morphingInfo?.targetEngineId + ) { + audioItem.morphingInfo = baseAudioItem.morphingInfo; + } return audioItem; }, }, @@ -670,6 +678,19 @@ export const audioStore = createPartialStore({ }, }, + SET_MORPHING_INFO: { + mutation( + state, + { + audioKey, + morphingInfo, + }: { audioKey: string; morphingInfo: MorphingInfo } + ) { + const item = state.audioItems[audioKey]; + item.morphingInfo = morphingInfo; + }, + }, + SET_AUDIO_QUERY: { mutation( state, @@ -721,6 +742,11 @@ export const audioStore = createPartialStore({ ) { state.audioItems[audioKey].engineId = engineId; state.audioItems[audioKey].styleId = styleId; + if ( + state.audioItems[audioKey].morphingInfo?.targetEngineId !== engineId + ) { + state.audioItems[audioKey].morphingInfo = undefined; + } }, }, @@ -1052,8 +1078,19 @@ export const audioStore = createPartialStore({ return dispatch("INSTANTIATE_ENGINE_CONNECTOR", { engineId, }) - .then((instance) => - instance.invoke("synthesisSynthesisPost")({ + .then((instance) => { + if (audioItem.morphingInfo) { + return instance.invoke("synthesisMorphingSynthesisMorphingPost")({ + audioQuery: convertAudioQueryFromEditorToEngine( + audioQuery, + state.engineManifests[engineId].defaultSamplingRate + ), + baseSpeaker: speaker, + targetSpeaker: audioItem.morphingInfo.targetStyleId, + morphRate: audioItem.morphingInfo.rate, + }); + } + return instance.invoke("synthesisSynthesisPost")({ audioQuery: convertAudioQueryFromEditorToEngine( audioQuery, state.engineManifests[engineId].defaultSamplingRate @@ -1061,8 +1098,8 @@ export const audioStore = createPartialStore({ speaker, enableInterrogativeUpspeak: state.experimentalSetting.enableInterrogativeUpspeak, - }) - ) + }); + }) .then(async (blob) => { audioBlobCache[id] = blob; return blob; @@ -2463,6 +2500,27 @@ export const audioCommandStore = transformCommandStore( }, }, + COMMAND_SET_MORPHING_INFO: { + mutation( + draft, + payload: { + audioKey: string; + morphingInfo: MorphingInfo; + } + ) { + audioStore.mutations.SET_MORPHING_INFO(draft, payload); + }, + action( + { commit }, + payload: { + audioKey: string; + morphingInfo: MorphingInfo; + } + ) { + commit("COMMAND_SET_MORPHING_INFO", payload); + }, + }, + COMMAND_SET_AUDIO_PRESET: { mutation( draft, diff --git a/src/store/type.ts b/src/store/type.ts index c50453c21a..be8aa36c44 100644 --- a/src/store/type.ts +++ b/src/store/type.ts @@ -29,6 +29,7 @@ import { ToolbarSetting, UpdateInfo, Preset, + MorphingInfo, ActivePointScrollMode, EngineInfo, SplitTextWhenPasteType, @@ -53,6 +54,7 @@ export type AudioItem = { styleId?: number; query?: EditorAudioQuery; presetKey?: string; + morphingInfo?: MorphingInfo; }; export type AudioState = { @@ -264,6 +266,13 @@ export type AudioStoreTypes = { mutation: { audioKey: string; postPhonemeLength: number }; }; + SET_MORPHING_INFO: { + mutation: { + audioKey: string; + morphingInfo: MorphingInfo; + }; + }; + SET_AUDIO_QUERY: { mutation: { audioKey: string; audioQuery: AudioQuery }; action(payload: { audioKey: string; audioQuery: AudioQuery }): void; @@ -576,6 +585,14 @@ export type AudioCommandStoreTypes = { action(payload: { audioKey: string; postPhonemeLength: number }): void; }; + COMMAND_SET_MORPHING_INFO: { + mutation: { + audioKey: string; + morphingInfo: MorphingInfo; + }; + action(payload: { audioKey: string; morphingInfo: MorphingInfo }): void; + }; + COMMAND_SET_AUDIO_PRESET: { mutation: { audioKey: string; diff --git a/src/type/preload.ts b/src/type/preload.ts index aa72e3a79f..e569103e66 100644 --- a/src/type/preload.ts +++ b/src/type/preload.ts @@ -205,6 +205,15 @@ export type Preset = { postPhonemeLength: number; }; +export type MorphingInfo = + | { + rate: number; + targetEngineId: string; + targetSpeakerId: string; + targetStyleId: number; + } + | undefined; + export type PresetConfig = { items: Record; keys: string[];