Skip to content

Commit

Permalink
アクセントからイントネーションを再設定する機能 (VOICEVOX#776)
Browse files Browse the repository at this point in the history
* FETCH_MORA_DATAで取ってきたaccentPhrasesでまるっと上書きするactionを追加

* ショートカットキーで実行できるように

* 何をリセットするのか明確にする

* FETCH_MORA_PITCHを追加してそちらを使うように

* デフォルトショートカットキーをRに変更

* FETCH_MORA_DATAを使い音素長もリセットする

* 長さも変更することを示すためaction名の変更
  • Loading branch information
k-chop authored Apr 3, 2022
1 parent 07f3497 commit 64044d1
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ const defaultHotkeySettings: HotkeySetting[] = [
action: "テキスト読み込む",
combination: "",
},
{
action: "イントネーションをリセット",
combination: "R",
},
];

const defaultToolbarButtonSetting: ToolbarSetting = [
Expand Down
10 changes: 10 additions & 0 deletions src/components/AudioDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,16 @@ export default defineComponent({
}
},
],
[
"イントネーションをリセット",
() => {
if (!uiLocked.value && store.getters.ACTIVE_AUDIO_KEY) {
store.dispatch("COMMAND_RESET_MORA_PITCH_AND_LENGTH", {
audioKey: store.getters.ACTIVE_AUDIO_KEY,
});
}
},
],
]);
// このコンポーネントは遅延評価なので手動でバインディングを行う
setHotkeyFunctions(hotkeyMap, true);
Expand Down
27 changes: 27 additions & 0 deletions src/store/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,33 @@ export const audioCommandStore: VoiceVoxStoreOptions<
});
}
},
async COMMAND_RESET_MORA_PITCH_AND_LENGTH(
{ state, dispatch, commit },
{ audioKey }
) {
const styleId = state.audioItems[audioKey].styleId;
if (styleId == undefined) throw new Error("styleId == undefined");

const query = state.audioItems[audioKey].query;
if (query == undefined) throw new Error("query == undefined");

try {
const newAccentPhases = await dispatch("FETCH_MORA_DATA", {
accentPhrases: query.accentPhrases,
styleId,
});

commit("COMMAND_CHANGE_ACCENT", {
audioKey,
accentPhrases: newAccentPhases,
});
} catch (error) {
commit("COMMAND_CHANGE_ACCENT", {
audioKey,
accentPhrases: query.accentPhrases,
});
}
},
COMMAND_SET_AUDIO_MORA_DATA(
{ commit },
payload: {
Expand Down
4 changes: 4 additions & 0 deletions src/store/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ type AudioCommandStoreTypes = {
}): void;
};

COMMAND_RESET_MORA_PITCH_AND_LENGTH: {
action(payload: { audioKey: string }): void;
};

COMMAND_SET_AUDIO_MORA_DATA: {
mutation: {
audioKey: string;
Expand Down
3 changes: 2 additions & 1 deletion src/type/preload.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ export type HotkeyAction =
| "プロジェクトを名前を付けて保存"
| "プロジェクトを上書き保存"
| "プロジェクト読み込み"
| "テキスト読み込む";
| "テキスト読み込む"
| "イントネーションをリセット";

export type HotkeyCombo = string;

Expand Down

0 comments on commit 64044d1

Please sign in to comment.