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 2 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
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
1 change: 1 addition & 0 deletions src/domain/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
projectData.audioItems[audioItemsKey].query.volumeScale = 1;
projectData.audioItems[audioItemsKey].query.prePhonemeLength = 0.1;
projectData.audioItems[audioItemsKey].query.postPhonemeLength = 0.1;
projectData.audioItems[audioItemsKey].query.pauseLengthScale = 1;
projectData.audioItems[audioItemsKey].query.outputSamplingRate =
DEFAULT_SAMPLING_RATE;
}
Expand Down Expand Up @@ -305,7 +306,7 @@
// Validation check
// トークはvalidateTalkProjectで検証する
// ソングはSET_SCOREの中の`isValidScore`関数で検証される
const parsedProjectData = projectSchema.parse(projectData);

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

View workflow job for this annotation

GitHub Actions / unit-test

../tests/unit/domain/project.node.spec.ts > migrateProjectFileObject > v0.14.11

ZodError: [ { "code": "invalid_type", "expected": "number", "received": "undefined", "path": [ "talk", "audioItems", "2add7ff5-0dfc-48b9-8aca-499c844afc30", "query", "pauseLengthScale" ], "message": "Required" }, { "code": "invalid_type", "expected": "number", "received": "undefined", "path": [ "talk", "audioItems", "073844d5-795b-4228-a93a-7e7cda9f22d5", "query", "pauseLengthScale" ], "message": "Required" }, { "code": "invalid_type", "expected": "number", "received": "undefined", "path": [ "talk", "audioItems", "be555d00-138d-4056-9c59-e0238b47501e", "query", "pauseLengthScale" ], "message": "Required" }, { "code": "invalid_type", "expected": "number", "received": "undefined", "path": [ "talk", "audioItems", "ef8165b5-55e9-4614-a91a-cab624f04677", "query", "pauseLengthScale" ], "message": "Required" }, { "code": "invalid_type", "expected": "number", "received": "undefined", "path": [ "talk", "audioItems", "0c29503e-174f-4734-991a-b878da6264bd", "query", "pauseLengthScale" ], "message": "Required" }, { "code": "invalid_type", "expected": "number", "received": "undefined", "path": [ "talk", "audioItems", "caadf97d-af33-4cd4-af37-a9230f58053a", "query", "pauseLengthScale" ], "message": "Required" }, { "code": "invalid_type", "expected": "number", "received": "undefined", "path": [ "talk", "audioItems", "def18555-b3e2-43c7-87c5-38dbb2d8bd09", "query", "pauseLengthScale" ], "message": "Required" }, { "code": "invalid_type", "expected": "number", "received": "undefined", "path": [ "talk", "audioItems", "7fa5212d-361a-4a05-8841-f2ec994859a4", "query", "pauseLengthScale" ], "message": "Required" }, { "code": "invalid_type", "expected": "number", "received": "undefined", "path": [ "talk", "audioItems", "f0115afa-9cfd-4846-adeb-d2943535dc6d", "query", "pauseLengthScale" ], "message": "Required" }, { "code": "invalid_type", "expected": "number", "received": "undefined", "path": [ "talk", "audioItems", "6a255bc3-ab1f-4ff6-b83f-57b369778c84", "query", "pauseLengthScale" ], "message": "Required" }, { "code": "invalid_type", "expected": "number", "received": "undefined", "path": [ "talk", "audioItems", "a2b69df2-7bcb-4bca-a7b5-fa50c3a6172a", "query", "pauseLengthScale" ], "message": "Required" }, { "code": "invalid_type", "expected": "number", "received": "undefined", "path": [ "talk", "audioItems", "232a6713-10f9-4960-a885-b7273ad6e3a4", "query", "pauseLengthScale" ], "message": "Required" }, { "code": "invalid_type", "expected": "number", "received": "undefined", "path": [ "talk", "audioItems", "b7413df6-dcef-4da5-9592-57745998434e", "query", "pauseLengthScale" ], "message": "Required" }, { "code": "invalid_type", "expected": "number", "received": "undefined", "path": [ "talk", "audioItems", "c86dd3dc-5469-4ef2-a6e6-c7820d948827", "query", "pauseLengthScale" ], "message": "Required" }, { "code": "invalid_type", "expected": "number", "received": "undefined", "path": [ "talk", "audioItems", "14177923-b252-4e7e-a2b4-f94d077d831c", "query", "pauseLengthScale" ], "message": "Required" }, { "code": "invalid_type", "expected": "number", "received": "undefined", "path": [ "talk", "audioItems", "cb2fe5b1-c56d-40c1-9094-28f3fa9c136d", "query",
validateTalkProject(parsedProjectData.talk);

return parsedProjectData;
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