forked from VOICEVOX/voicevox
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: 1~10番目のキャラクターを選択するホットキーを追加 (VOICEVOX#2034)
* characterSelectShortcutの関数渡しを一段回減らす * add: キーバインドと型設定 * fix: 型の修正 ビルド失敗の修正 * 変更commit --------- Co-authored-by: Hiroshiba <[email protected]> Co-authored-by: Hiroshiba Kazuyuki <[email protected]>
- Loading branch information
1 parent
c1d5c7a
commit 1c645f4
Showing
5 changed files
with
104 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { CharacterInfo, DefaultStyleId, SpeakerId } from "@/type/preload"; | ||
|
||
/** 話者に対応するデフォルトスタイルを取得する */ | ||
export const getDefaultStyle = ( | ||
speakerUuid: SpeakerId, | ||
characterInfos: CharacterInfo[], | ||
defaultStyleIds: DefaultStyleId[], | ||
) => { | ||
// FIXME: 同一キャラが複数エンジンにまたがっているとき、順番が先のエンジンが必ず選択される | ||
const characterInfo = characterInfos.find( | ||
(info) => info.metas.speakerUuid === speakerUuid, | ||
); | ||
const defaultStyleId = defaultStyleIds.find( | ||
(x) => x.speakerUuid === speakerUuid, | ||
)?.defaultStyleId; | ||
|
||
const defaultStyle = | ||
characterInfo?.metas.styles.find( | ||
(style) => style.styleId === defaultStyleId, | ||
) ?? characterInfo?.metas.styles[0]; // デフォルトのスタイルIDが見つからない場合stylesの先頭を選択する | ||
|
||
if (defaultStyle == undefined) throw new Error("defaultStyle == undefined"); | ||
|
||
return defaultStyle; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters