mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-17 00:30:45 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
90
openclaw/extensions/minimax/tts.ts
Normal file
90
openclaw/extensions/minimax/tts.ts
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
export const DEFAULT_MINIMAX_TTS_BASE_URL = "https://api.minimax.io";
|
||||
|
||||
export const MINIMAX_TTS_MODELS = ["speech-2.8-hd", "speech-01-240228"] as const;
|
||||
|
||||
export const MINIMAX_TTS_VOICES = [
|
||||
"English_expressive_narrator",
|
||||
"Chinese (Mandarin)_Warm_Girl",
|
||||
"Chinese (Mandarin)_Lively_Girl",
|
||||
"Chinese (Mandarin)_Gentle_Boy",
|
||||
"Chinese (Mandarin)_Steady_Boy",
|
||||
] as const;
|
||||
|
||||
export function normalizeMinimaxTtsBaseUrl(baseUrl?: string): string {
|
||||
const trimmed = baseUrl?.trim();
|
||||
if (!trimmed) {
|
||||
return DEFAULT_MINIMAX_TTS_BASE_URL;
|
||||
}
|
||||
return trimmed.replace(/\/+$/, "");
|
||||
}
|
||||
|
||||
export async function minimaxTTS(params: {
|
||||
text: string;
|
||||
apiKey: string;
|
||||
baseUrl: string;
|
||||
model: string;
|
||||
voiceId: string;
|
||||
speed?: number;
|
||||
vol?: number;
|
||||
pitch?: number;
|
||||
format?: string;
|
||||
sampleRate?: number;
|
||||
timeoutMs: number;
|
||||
}): Promise<Buffer> {
|
||||
const {
|
||||
text,
|
||||
apiKey,
|
||||
baseUrl,
|
||||
model,
|
||||
voiceId,
|
||||
speed = 1.0,
|
||||
vol = 1.0,
|
||||
pitch = 0,
|
||||
format = "mp3",
|
||||
sampleRate = 32000,
|
||||
timeoutMs,
|
||||
} = params;
|
||||
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
||||
|
||||
try {
|
||||
const response = await fetch(`${baseUrl}/v1/t2a_v2`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${apiKey}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model,
|
||||
text,
|
||||
voice_setting: {
|
||||
voice_id: voiceId,
|
||||
speed,
|
||||
vol,
|
||||
pitch,
|
||||
},
|
||||
audio_setting: {
|
||||
format,
|
||||
sample_rate: sampleRate,
|
||||
},
|
||||
}),
|
||||
signal: controller.signal,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errBody = await response.text().catch(() => "");
|
||||
throw new Error(`MiniMax TTS API error (${response.status})${errBody ? `: ${errBody}` : ""}`);
|
||||
}
|
||||
|
||||
const body = (await response.json()) as { data?: { audio?: string } };
|
||||
const hexAudio = body?.data?.audio;
|
||||
if (!hexAudio) {
|
||||
throw new Error("MiniMax TTS API returned no audio data");
|
||||
}
|
||||
|
||||
return Buffer.from(hexAudio, "hex");
|
||||
} finally {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue