Skip to content

Commit

Permalink
fix 歌wave出力時のデフォルトファイル名を変更 (VOICEVOX#1859)
Browse files Browse the repository at this point in the history
* fix 歌wave出力時のデフォルトファイル名を変更

* refactor: 歌waveのデフォルトファイル名を変更する処理を関数に切り出し

* 細かい変更

---------

Co-authored-by: Hiroshiba <[email protected]>
  • Loading branch information
P0ngCh4ng and Hiroshiba authored Feb 20, 2024
1 parent 008f020 commit 3e18a72
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/store/singing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
PhraseState,
transformCommandStore,
} from "./type";
import { sanitizeFileName } from "./utility";
import { EngineId } from "@/type/preload";
import { FrameAudioQuery, Note as NoteForRequestToEngine } from "@/openapi";
import { ResultError, getValueOrThrow } from "@/type/result";
Expand Down Expand Up @@ -1785,8 +1786,34 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
return Math.max(1, lastNoteEndTime + 1);
};

const generateDefaultSongFileName = () => {
const projectName = getters.PROJECT_NAME;
if (projectName) {
return projectName.split(".")[0] + ".wav";
}

const singer = getters.SELECTED_TRACK.singer;
if (singer) {
const singerName = getters.CHARACTER_INFO(
singer.engineId,
singer.styleId
)?.metas.speakerName;
if (singerName) {
const notes = getters.SELECTED_TRACK.notes.slice(0, 5);
const beginningPartLyrics = notes
.map((note) => note.lyric)
.join("");
return sanitizeFileName(
`${singerName}_${beginningPartLyrics}.wav`
);
}
}

return "Untitled.wav";
};

const exportWaveFile = async (): Promise<SaveResultObject> => {
const fileName = "test_export.wav"; // TODO: 設定できるようにする
const fileName = generateDefaultSongFileName();
const numberOfChannels = 2;
const sampleRate = 48000; // TODO: 設定できるようにする
const withLimiter = false; // TODO: 設定できるようにする
Expand Down

0 comments on commit 3e18a72

Please sign in to comment.