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

ソング:音量が正しく生成されていないのを修正 #2030

Merged
merged 3 commits into from
Apr 28, 2024
Merged
Changes from all 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
22 changes: 16 additions & 6 deletions src/store/singing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1338,8 +1338,8 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
`Fetched frame audio query. Phonemes are "${phonemes}".`,
);

// 音域調整を適用する
shiftGuidePitch(keyRangeAdjustment, query);
scaleGuideVolume(volumeRangeAdjustment, query);

const startTime = calcStartTime(
phrase.notes,
Expand All @@ -1363,9 +1363,12 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
});
}

// 歌い方をコピーして、ピッチ編集を適用する
// ピッチ編集を適用する前に、歌い方をコピーする

singingGuide = structuredClone(toRaw(singingGuide));

// ピッチ編集を適用する

applyPitchEdit(singingGuide, pitchEditData, editFrameRate);

// 歌声のキャッシュがあれば取得し、なければ音声合成を行う
Expand All @@ -1385,24 +1388,31 @@ export const singingStore = createPartialStore<SingingStoreTypes>({

logger.info(`Loaded singing voice from cache.`);
} else {
// ピッチ編集を適用したクエリから音量を作る
// 音量生成用のクエリを作る
// ピッチ編集を適用したクエリをコピーし、
// f0をもう一度シフトして、f0生成時の(シフトする前の)高さに戻す
const queryForVolume = structuredClone(singingGuide.query);
shiftGuidePitch(-keyRangeAdjustment, queryForVolume);

// 音量生成用のクエリから音量を作る
// 音量値はAPIを叩く毎に変わるので、calc hashしたあとに音量を取得している
const notesForRequestToEngine = createNotesForRequestToEngine(
phrase.notes,
tempos,
tpqn,
keyRangeAdjustment,
keyRangeAdjustment, // f0を生成するときと同様に、noteのkeyのシフトを行う
singingGuide.frameRate,
restDurationSeconds,
);

const volumes = await dispatch("FETCH_SING_FRAME_VOLUME", {
notes: notesForRequestToEngine,
frameAudioQuery: singingGuide.query,
frameAudioQuery: queryForVolume,
styleId: singingTeacherStyleId,
engineId: singerAndFrameRate.singer.engineId,
});
singingGuide.query.volume = volumes;

// 声量調整を適用する
scaleGuideVolume(volumeRangeAdjustment, singingGuide.query);

const blob = await synthesize(
Expand Down
Loading