UNPKG

app-walk

Version:

An intuitive guided walkthrough library with UI highlighting and voice narration for web apps.

19 lines (18 loc) 686 B
import { promisify } from "./utils/promisify"; export function speakTextWithCallback(text, callback) { if ("speechSynthesis" in window) { const utterance = new SpeechSynthesisUtterance(text); utterance.pitch = 1; utterance.rate = 1; utterance.volume = 1; utterance.onend = () => callback(null); utterance.onerror = (event) => callback(new Error(event.error || "Speech synthesis error")); window.speechSynthesis.speak(utterance); } else { callback(new Error("Speech Synthesis not supported in this browser.")); } } export function speakTextAsync(text) { return promisify(speakTextWithCallback)(text); }