Anonymous
Publish PromptDialog dataset and PromptTTSD listening demos
cfaa94b
Raw History Blame Contribute Delete
791 Bytes
export async function fetchText(path) {
const response = await fetch(path, { cache: "no-cache" });
if (!response.ok) {
throw new Error(`Failed to load ${path}`);
}
return response.text();
}
export function createAudio(src) {
const audio = document.createElement("audio");
audio.controls = true;
audio.preload = "none";
audio.src = src;
audio.setAttribute("aria-label", "Play speech sample");
audio.addEventListener("play", () => {
document.querySelectorAll("audio").forEach((other) => {
if (other !== audio) other.pause();
});
});
return audio;
}
export function escapeHtml(text) {
return String(text ?? "").replace(/[&<>"']/g, (char) => ({
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': "&quot;",
"'": "&#039;"
}[char]));
}