Files
learn-languages/src/lib/tts.ts
goddonebianu 3db1b3716f
Some checks reported errors
continuous-integration/drone/push Build was killed
重构了translator,写了点数据库、后端api路由
2025-11-10 21:40:25 +08:00

17 lines
425 B
TypeScript

import { ProsodyOptions } from "edge-tts-universal";
import { EdgeTTS } from "edge-tts-universal/browser";
export async function getTTSAudioUrl(
text: string,
short_name: string,
options: ProsodyOptions | undefined = undefined,
) {
const tts = new EdgeTTS(text, short_name, options);
try {
const result = await tts.synthesize();
return URL.createObjectURL(result.audio);
} catch (e) {
throw e;
}
}