Skip to content

Instantly share code, notes, and snippets.

View Virus5600's full-sized avatar
📚
Back to college

Karl Satchi Navida Virus5600

📚
Back to college
View GitHub Profile
@Virus5600
Virus5600 / Browser TTS.js
Last active March 8, 2024 03:52
Random Gists
/**
* Synthesizes speech from the provided text using the Web Speech API.
* @param {string} text - The text to be synthesized.
* @param {string} voiceName - The name of the voice to be used.
*/
function speak(text, voiceName) {
const utterance = new SpeechSynthesisUtterance(text);
const voices = window.speechSynthesis.getVoices();
// Find the voice with the specified name