chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:58:18 +08:00
commit 6d5d58c1a9
18293 changed files with 3502153 additions and 0 deletions
@@ -0,0 +1,25 @@
"use client";
export let globalAudio: any = undefined;
export function resetGlobalAudio() {
if (globalAudio) {
globalAudio.pause();
globalAudio.currentTime = 0;
} else {
globalAudio = new Audio();
}
}
export async function speak(text: string) {
const encodedText = encodeURIComponent(text);
const url = `/api/tts?text=${encodedText}`;
globalAudio.src = url;
globalAudio.play();
await new Promise<void>((resolve) => {
globalAudio.onended = function () {
resolve();
};
});
await new Promise((resolve) => setTimeout(resolve, 500));
}