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

音声をすべて繋げて書き出す機能を追加 #549

Merged
merged 18 commits into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from 16 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
4 changes: 4 additions & 0 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ const defaultHotkeySettings: HotkeySetting[] = [
action: "一つだけ書き出し",
combination: "E",
},
{
action: "音声を繋げて書き出し",
combination: "",
},
{
action: "再生/停止",
combination: "Space",
Expand Down
46 changes: 46 additions & 0 deletions src/components/Dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,49 @@ export async function generateAndSaveAllAudioWithDialog({
});
}
}

export async function generateAndConnectAndSaveAudioWithDialog({
quasarDialog,
dispatch,
filePath,
encoding,
}: {
quasarDialog: QuasarDialog;
dispatch: Dispatch<AllActions>;
filePath?: string;
encoding?: EncodingType;
}): Promise<void> {
const result = await dispatch("GENERATE_AND_CONNECT_AND_SAVE_AUDIO", {
filePath,
encoding,
});

if (
result === undefined ||
result.result === "SUCCESS" ||
result.result === "CANCELED"
)
return;

let msg = "";
switch (result.result) {
case "WRITE_ERROR":
msg =
"書き込みエラーによって失敗しました。空き容量があることや、書き込み権限があることをご確認ください。";
break;
case "ENGINE_ERROR":
msg =
"エンジンのエラーによって失敗しました。エンジンの再起動をお試しください。";
break;
}

quasarDialog({
title: "書き出しに失敗しました。",
message: msg,
ok: {
label: "閉じる",
flat: true,
textColor: "secondary",
},
});
}
19 changes: 19 additions & 0 deletions src/components/MenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { useQuasar } from "quasar";
import { HotkeyAction, HotkeyReturnType } from "@/type/preload";
import { setHotkeyFunctions } from "@/store/setting";
import {
generateAndConnectAndSaveAudioWithDialog,
generateAndSaveAllAudioWithDialog,
generateAndSaveOneAudioWithDialog,
} from "@/components/Dialog";
Expand Down Expand Up @@ -103,6 +104,16 @@ export default defineComponent({
}
};

const generateAndConnectAndSaveAllAudio = async () => {
if (!uiLocked.value) {
await generateAndConnectAndSaveAudioWithDialog({
quasarDialog: $q.dialog,
dispatch: store.dispatch,
encoding: store.state.savingSetting.fileEncoding,
});
}
};

const generateAndSaveOneAudio = async () => {
if (uiLocked.value) return;

Expand Down Expand Up @@ -199,6 +210,13 @@ export default defineComponent({
generateAndSaveOneAudio();
},
},
{
type: "button",
label: "音声を繋げて書き出し",
onClick: () => {
generateAndConnectAndSaveAllAudio();
},
},
{
type: "button",
label: "テキスト読み込み",
Expand Down Expand Up @@ -313,6 +331,7 @@ export default defineComponent({
["新規プロジェクト", createNewProject],
["音声書き出し", generateAndSaveAllAudio],
["一つだけ書き出し", generateAndSaveOneAudio],
["音声を繋げて書き出し", generateAndConnectAndSaveAllAudio],
["テキスト読み込む", importTextFile],
["プロジェクトを上書き保存", saveProject],
["プロジェクトを名前を付けて保存", saveProjectAs],
Expand Down
Loading