This commit is contained in:
rookie
2024-11-06 15:28:32 +08:00
committed by GitHub
25 changed files with 582 additions and 8 deletions

View File

@@ -5,6 +5,9 @@ import {
DEFAULT_INPUT_TEMPLATE,
DEFAULT_MODELS,
DEFAULT_SIDEBAR_WIDTH,
DEFAULT_STT_ENGINE,
DEFAULT_STT_ENGINES,
DEFAULT_STT_LANGUAGE,
DEFAULT_TTS_ENGINE,
DEFAULT_TTS_ENGINES,
DEFAULT_TTS_MODEL,
@@ -20,6 +23,7 @@ export type ModelType = (typeof DEFAULT_MODELS)[number]["name"];
export type TTSModelType = (typeof DEFAULT_TTS_MODELS)[number];
export type TTSVoiceType = (typeof DEFAULT_TTS_VOICES)[number];
export type TTSEngineType = (typeof DEFAULT_TTS_ENGINES)[number];
export type STTEngineType = (typeof DEFAULT_STT_ENGINES)[number];
export enum SubmitKey {
Enter = "Enter",
@@ -83,19 +87,25 @@ export const DEFAULT_CONFIG = {
},
ttsConfig: {
enable: false,
enable: true,
autoplay: false,
engine: DEFAULT_TTS_ENGINE,
model: DEFAULT_TTS_MODEL,
voice: DEFAULT_TTS_VOICE,
speed: 1.0,
},
sttConfig: {
enable: true,
engine: DEFAULT_STT_ENGINE,
lang: DEFAULT_STT_LANGUAGE,
},
};
export type ChatConfig = typeof DEFAULT_CONFIG;
export type ModelConfig = ChatConfig["modelConfig"];
export type TTSConfig = ChatConfig["ttsConfig"];
export type STTConfig = ChatConfig["sttConfig"];
export function limitNumber(
x: number,
@@ -125,6 +135,12 @@ export const TTSConfigValidator = {
},
};
export const STTConfigValidator = {
engine(x: string) {
return x as STTEngineType;
},
};
export const ModalConfigValidator = {
model(x: string) {
return x as ModelType;