Skip to content

Commit

Permalink
ENH: テキスト読み込みで最初に選択されるスタイルを引き継ぎするようにした (VOICEVOX#1198)
Browse files Browse the repository at this point in the history
  • Loading branch information
sabonerune authored Feb 12, 2023
1 parent 1b1ae81 commit 2f98316
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/store/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ async function generateUniqueIdAndQuery(
function parseTextFile(
body: string,
defaultStyleIds: DefaultStyleId[],
userOrderedCharacterInfos: CharacterInfo[]
userOrderedCharacterInfos: CharacterInfo[],
initVoice?: Voice
): AudioItem[] {
const name2Voice = new Map<string, Voice>();
const uuid2Voice = new Map<string, Voice>();
Expand Down Expand Up @@ -104,9 +105,8 @@ function parseTextFile(

const audioItems: AudioItem[] = [];
const seps = [",", "\r\n", "\n"];
let lastVoice = uuid2Voice.get(
userOrderedCharacterInfos[0].metas.speakerUuid
);
let lastVoice =
initVoice ?? uuid2Voice.get(userOrderedCharacterInfos[0].metas.speakerUuid);
if (lastVoice == undefined) throw new Error(`lastStyle is undefined.`);
for (const splitText of body.split(new RegExp(`${seps.join("|")}`, "g"))) {
const voice = name2Voice.get(splitText);
Expand Down Expand Up @@ -2699,7 +2699,8 @@ export const audioCommandStore = transformCommandStore(
for (const { text, voice } of parseTextFile(
body,
state.defaultStyleIds,
getters.USER_ORDERED_CHARACTER_INFOS
getters.USER_ORDERED_CHARACTER_INFOS,
baseAudioItem?.voice
)) {
//パラメータ引き継ぎがONの場合は話速等のパラメータを引き継いでテキスト欄を作成する
//パラメータ引き継ぎがOFFの場合、baseAudioItemがundefinedになっているのでパラメータ引き継ぎは行われない
Expand Down

0 comments on commit 2f98316

Please sign in to comment.