feat: 添加 TTS 引擎配置,更新阿里巴巴语音接口,支持实时语音合成

This commit is contained in:
EvanWu
2025-07-30 21:30:49 +08:00
parent 557a2cce35
commit 9990a89698
9 changed files with 241 additions and 45 deletions

View File

@@ -13,6 +13,8 @@ import {
DEFAULT_TTS_VOICES,
StoreKey,
ServiceProvider,
TTSEngineType,
ModelProvider,
} from "../constant";
import { createPersistStore } from "../utils/store";
import type { Voice } from "rt-client";
@@ -20,7 +22,6 @@ import type { Voice } from "rt-client";
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 enum SubmitKey {
Enter = "Enter",
@@ -86,7 +87,8 @@ export const DEFAULT_CONFIG = {
ttsConfig: {
enable: false,
autoplay: false,
engine: DEFAULT_TTS_ENGINE,
modelProvider: ModelProvider.GPT,
engine: DEFAULT_TTS_ENGINE as TTSEngineType,
model: DEFAULT_TTS_MODEL,
voice: DEFAULT_TTS_VOICE,
speed: 1.0,
@@ -126,18 +128,21 @@ export function limitNumber(
}
export const TTSConfigValidator = {
engine(x: string) {
engine(x: string | TTSEngineType): TTSEngineType {
return x as TTSEngineType;
},
model(x: string) {
model(x: string): TTSModelType {
return x as TTSModelType;
},
voice(x: string) {
voice(x: string): TTSVoiceType {
return x as TTSVoiceType;
},
speed(x: number) {
speed(x: number): number {
return limitNumber(x, 0.25, 4.0, 1.0);
},
modelProvider(x: string): ModelProvider {
return x as ModelProvider;
},
};
export const ModalConfigValidator = {