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 4 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
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 @@ -470,6 +470,24 @@ const parameterConfigs = computed<ParameterConfig[]>(() => [
}),
key: "postPhonemeLength",
},
{
label: "文内無音倍率",
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
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",
},
]);

/** パラメーター制御用 */
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 @@ -302,6 +302,14 @@
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;
console.log(projectData.talk.audioItems[audioItemsKey].query);

Check warning on line 309 in src/domain/project/index.ts

View workflow job for this annotation

GitHub Actions / build_preview_pages

Unexpected console statement

Check warning on line 309 in src/domain/project/index.ts

View workflow job for this annotation

GitHub Actions / build_preview_pages

Unexpected console statement

Check warning on line 309 in src/domain/project/index.ts

View workflow job for this annotation

GitHub Actions / build-test

Unexpected console statement
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
}
}

// 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 @@ -35,6 +35,7 @@ const audioQuerySchema = z.object({
volumeScale: z.number(),
prePhonemeLength: z.number(),
postPhonemeLength: z.number(),
pauseLengthScale: z.number(),
outputSamplingRate: z.union([z.number(), z.literal("engineDefault")]),
outputStereo: z.boolean(),
kana: z.string().optional(),
Expand Down
3 changes: 2 additions & 1 deletion src/openapi/models/AudioQuery.ts

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

3 changes: 2 additions & 1 deletion src/openapi/models/Preset.ts

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

47 changes: 46 additions & 1 deletion src/store/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,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 @@ -919,6 +921,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_MORPHING_INFO: {
mutation(
state,
Expand Down Expand Up @@ -1271,7 +1290,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 @@ -2751,6 +2773,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(
{ commit },
payload: { audioKeys: AudioKey[]; pauseLengthScale: number },
) {
commit("COMMAND_MULTI_SET_AUDIO_PAUSE_LENGTH_SCALE", payload);
},
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
},

COMMAND_MULTI_SET_MORPHING_INFO: {
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 @@ -224,6 +224,7 @@ export const presetStore = createPartialStore<PresetStoreTypes>({
volumeScale: 1.0,
prePhonemeLength: 0.1,
postPhonemeLength: 0.1,
pauseLengthScale: 1,
};
const newPresetKey = await actions.ADD_PRESET({ presetData });

Expand Down
9 changes: 9 additions & 0 deletions src/store/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ export type AudioStoreTypes = {
mutation: { audioKey: AudioKey; postPhonemeLength: number };
};

SET_AUDIO_PAUSE_LENGTH_SCALE: {
mutation: { audioKey: AudioKey; pauseLengthScale: number };
};

LOAD_MORPHABLE_TARGETS: {
action(payload: { engineId: EngineId; baseStyleId: StyleId }): void;
};
Expand Down Expand Up @@ -637,6 +641,11 @@ export type AudioCommandStoreTypes = {
action(payload: { audioKeys: AudioKey[]; postPhonemeLength: number }): void;
};

COMMAND_MULTI_SET_AUDIO_PAUSE_LENGTH_SCALE: {
mutation: { audioKeys: AudioKey[]; pauseLengthScale: number };
action(payload: { audioKeys: AudioKey[]; pauseLengthScale: number }): void;
};

COMMAND_MULTI_SET_MORPHING_INFO: {
mutation: {
audioKeys: AudioKey[];
Expand Down
10 changes: 10 additions & 0 deletions src/store/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ export const SLIDER_PARAMETERS = {
scrollStep: () => 0.1,
scrollMinStep: () => 0.01,
},
/**
* 文内無音(倍率)パラメータの定義
*/
PAUSE_LENGTH_SCALE: {
max: () => 2,
min: () => 0,
step: () => 0.01,
scrollStep: () => 0.1,
scrollMinStep: () => 0.01,
},
/**
* モーフィングレートパラメータの定義
*/
Expand Down
2 changes: 2 additions & 0 deletions src/type/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ export type Preset = {
volumeScale: number;
prePhonemeLength: number;
postPhonemeLength: number;
pauseLengthScale: number;
morphingInfo?: MorphingInfo;
};

Expand Down Expand Up @@ -645,6 +646,7 @@ export const configSchema = z
volumeScale: z.number(),
prePhonemeLength: z.number(),
postPhonemeLength: z.number(),
pauseLengthScale: z.number(),
morphingInfo: z
.object({
rate: z.number(),
Expand Down
Loading