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

追加: 文内無音倍率 #2352

Merged
merged 14 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
2 changes: 1 addition & 1 deletion openapi.json
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/backend/common/ConfigManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,17 @@ const migrations: [string, (store: Record<string, unknown>) => unknown][] = [
return config;
},
],
[
">=0.22",
(config) => {
// プリセットに文内無音倍率を追加
const presets = config.presets as ConfigType["presets"];
for (const preset of Object.values(presets.items)) {
if (preset == undefined) throw new Error("preset == undefined");
preset.pauseLengthScale = 1;
}
},
],
];

export type Metadata = {
Expand Down
18 changes: 18 additions & 0 deletions src/components/Talk/AudioInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,24 @@ const parameterConfigs = computed<ParameterConfig[]>(() => [
}),
key: "volumeScale",
},
{
label: "文内無音倍率",
sliderProps: {
modelValue: () => query.value?.pauseLengthScale ?? null,
disable: () => uiLocked.value,
max: SLIDER_PARAMETERS.PAUSE_LENGTH_SCALE.max,
min: SLIDER_PARAMETERS.PAUSE_LENGTH_SCALE.min,
step: SLIDER_PARAMETERS.PAUSE_LENGTH_SCALE.step,
scrollStep: SLIDER_PARAMETERS.PAUSE_LENGTH_SCALE.scrollStep,
scrollMinStep: SLIDER_PARAMETERS.PAUSE_LENGTH_SCALE.scrollMinStep,
},
onChange: (pauseLengthScale: number) =>
store.actions.COMMAND_MULTI_SET_AUDIO_PAUSE_LENGTH_SCALE({
audioKeys: selectedAudioKeys.value,
pauseLengthScale,
}),
key: "pauseLengthScale",
},
{
label: "開始無音",
sliderProps: {
Expand Down
8 changes: 8 additions & 0 deletions src/domain/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export const migrateProjectFileObject = async (
for (const audioItemsKey in projectData.audioItems) {
if (projectData.audioItems[audioItemsKey].query != null) {
projectData.audioItems[audioItemsKey].query.volumeScale = 1;
projectData.audioItems[audioItemsKey].query.pauseLengthScale = 1;
projectData.audioItems[audioItemsKey].query.prePhonemeLength = 0.1;
projectData.audioItems[audioItemsKey].query.postPhonemeLength = 0.1;
projectData.audioItems[audioItemsKey].query.outputSamplingRate =
Expand Down Expand Up @@ -302,6 +303,13 @@ export const migrateProjectFileObject = async (
projectData.song.trackOrder = Object.keys(newTracks);
}

if (semver.satisfies(projectAppVersion, "<0.22.0", semverSatisfiesOptions)) {
// 文内無音倍率の追加
for (const audioItemsKey in projectData.talk.audioItems) {
projectData.talk.audioItems[audioItemsKey].query.pauseLengthScale = 1;
}
}

// Validation check
// トークはvalidateTalkProjectで検証する
// ソングはSET_SCOREの中の`isValidScore`関数で検証される
Expand Down
1 change: 1 addition & 0 deletions src/domain/project/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const audioQuerySchema = z.object({
pitchScale: z.number(),
intonationScale: z.number(),
volumeScale: z.number(),
pauseLengthScale: z.number(),
prePhonemeLength: z.number(),
postPhonemeLength: z.number(),
outputSamplingRate: z.union([z.number(), z.literal("engineDefault")]),
Expand Down
16 changes: 8 additions & 8 deletions src/openapi/models/AudioQuery.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions src/openapi/models/Preset.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 64 additions & 12 deletions src/store/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
AudioCommandStoreTypes,
transformCommandStore,
FetchAudioResult,
EditorAudioQuery,
} from "./type";
import {
buildAudioFileNameFromRawData,
Expand All @@ -34,6 +35,7 @@ import {
isMorphable,
} from "./audioGenerate";
import { ContinuousPlayer } from "./audioContinuousPlayer";
import { convertAudioQueryFromEngineToEditor } from "./proxy";
import {
convertHiraToKana,
convertLongVowel,
Expand Down Expand Up @@ -739,6 +741,8 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
baseAudioItem.query.prePhonemeLength;
newAudioItem.query.postPhonemeLength =
baseAudioItem.query.postPhonemeLength;
newAudioItem.query.pauseLengthScale =
baseAudioItem.query.pauseLengthScale;
Comment on lines +744 to +745
Copy link
Member

@Hiroshiba Hiroshiba Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あ、ここ順番変わってなそうですね!
ちょっとこちらで変えさせていただこうと思います!

(追記:変更忘れていました・・・。)

newAudioItem.query.outputSamplingRate =
baseAudioItem.query.outputSamplingRate;
newAudioItem.query.outputStereo = baseAudioItem.query.outputStereo;
Expand Down Expand Up @@ -891,6 +895,23 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
},
},

SET_AUDIO_PAUSE_LENGTH_SCALE: {
mutation(
state,
{
audioKey,
pauseLengthScale,
}: {
audioKey: AudioKey;
pauseLengthScale: number;
},
) {
const query = state.audioItems[audioKey].query;
if (query == undefined) throw new Error("query == undefined");
query.pauseLengthScale = pauseLengthScale;
},
},

SET_AUDIO_PRE_PHONEME_LENGTH: {
mutation(
state,
Expand Down Expand Up @@ -949,13 +970,16 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
SET_AUDIO_QUERY: {
mutation(
state,
{ audioKey, audioQuery }: { audioKey: AudioKey; audioQuery: AudioQuery },
{
audioKey,
audioQuery,
}: { audioKey: AudioKey; audioQuery: EditorAudioQuery },
) {
state.audioItems[audioKey].query = audioQuery;
},
action(
{ mutations },
payload: { audioKey: AudioKey; audioQuery: AudioQuery },
payload: { audioKey: AudioKey; audioQuery: EditorAudioQuery },
) {
mutations.SET_AUDIO_QUERY(payload);
},
Expand All @@ -974,11 +998,13 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
.INSTANTIATE_ENGINE_CONNECTOR({
engineId,
})
.then((instance) =>
instance.invoke("audioQueryAudioQueryPost")({
text,
speaker: styleId,
}),
.then(async (instance) =>
convertAudioQueryFromEngineToEditor(
await instance.invoke("audioQueryAudioQueryPost")({
text,
speaker: styleId,
}),
),
)
.catch((error) => {
window.backend.logError(
Expand Down Expand Up @@ -1271,7 +1297,10 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
length += m.consonantLength != undefined ? m.consonantLength : 0;
length += m.vowelLength;
});
length += phrase.pauseMora ? phrase.pauseMora.vowelLength : 0;
if (phrase.pauseMora != null && query.pauseLengthScale != undefined) {
const pauseLength = phrase.pauseMora.vowelLength;
length += pauseLength * query.pauseLengthScale;
}
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
// post phoneme lengthは最後のアクセント句の一部として扱う
if (i === accentPhrases.length - 1) {
length += query.postPhonemeLength;
Expand Down Expand Up @@ -1919,7 +1948,7 @@ export const audioCommandStore = transformCommandStore(
payload: { audioKey: AudioKey; text: string } & (
| { update: "Text" }
| { update: "AccentPhrases"; accentPhrases: AccentPhrase[] }
| { update: "AudioQuery"; query: AudioQuery }
| { update: "AudioQuery"; query: EditorAudioQuery }
),
) {
audioStore.mutations.SET_AUDIO_TEXT(draft, {
Expand Down Expand Up @@ -2025,7 +2054,7 @@ export const audioCommandStore = transformCommandStore(
}
| {
update: "AudioQuery";
query: AudioQuery;
query: EditorAudioQuery;
}
| {
update: "OnlyVoice";
Expand Down Expand Up @@ -2089,7 +2118,7 @@ export const audioCommandStore = transformCommandStore(
}
| {
update: "AudioQuery";
query: AudioQuery;
query: EditorAudioQuery;
}
| {
update: "OnlyVoice";
Expand All @@ -2100,7 +2129,7 @@ export const audioCommandStore = transformCommandStore(
try {
const audioItem = state.audioItems[audioKey];
if (audioItem.query == undefined) {
const query: AudioQuery = await actions.FETCH_AUDIO_QUERY({
const query = await actions.FETCH_AUDIO_QUERY({
text: audioItem.text,
engineId: voice.engineId,
styleId: voice.styleId,
Expand Down Expand Up @@ -2711,6 +2740,29 @@ export const audioCommandStore = transformCommandStore(
},
},

COMMAND_MULTI_SET_AUDIO_PAUSE_LENGTH_SCALE: {
mutation(
draft,
payload: {
audioKeys: AudioKey[];
pauseLengthScale: number;
},
) {
for (const audioKey of payload.audioKeys) {
audioStore.mutations.SET_AUDIO_PAUSE_LENGTH_SCALE(draft, {
audioKey,
pauseLengthScale: payload.pauseLengthScale,
});
}
},
action(
{ mutations },
payload: { audioKeys: AudioKey[]; pauseLengthScale: number },
) {
mutations.COMMAND_MULTI_SET_AUDIO_PAUSE_LENGTH_SCALE(payload);
},
},

COMMAND_MULTI_SET_AUDIO_PRE_PHONEME_LENGTH: {
mutation(
draft,
Expand Down
1 change: 1 addition & 0 deletions src/store/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export const presetStore = createPartialStore<PresetStoreTypes>({
pitchScale: 0.0,
intonationScale: 1.0,
volumeScale: 1.0,
pauseLengthScale: 1,
prePhonemeLength: 0.1,
postPhonemeLength: 0.1,
};
Expand Down
11 changes: 11 additions & 0 deletions src/store/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const proxyStoreCreator = (_engineFactory: IEngineConnectorFactory) => {
return proxyStore;
};

/** AudioQueryをエンジン用に変換する */
export const convertAudioQueryFromEditorToEngine = (
editorAudioQuery: EditorAudioQuery,
defaultOutputSamplingRate: number,
Expand All @@ -56,4 +57,14 @@ export const convertAudioQueryFromEditorToEngine = (
};
};

/** AudioQueryをエディタ用に変換する */
export const convertAudioQueryFromEngineToEditor = (
engineAudioQuery: AudioQuery,
): EditorAudioQuery => {
return {
...engineAudioQuery,
pauseLengthScale: engineAudioQuery.pauseLengthScale ?? 1,
};
};

export const proxyStore = proxyStoreCreator(OpenAPIEngineConnectorFactory);
Loading
Loading