UNPKG

voice-tts

Version:

Universal Text-to-Speech voice management library

31 lines 988 B
import { Voice } from './Voice'; const createElement = (tagName, innerText, onclick) => { const $element = document.createElement(tagName); if (innerText) { $element.innerText = innerText; } if (onclick) { $element.onclick = onclick; } return $element; }; (async () => { const voice = new Voice(); await voice.init(); const $ul = createElement('div'); voice.speechSynthesisVoices.forEach((item) => { const $li = createElement('div'); const $playButton = createElement('button', '⏵', () => { voice.change(item.name); voice.speak('Привет, мир!'); }); const $spacer = createElement('span', ' '); const $text = createElement('span', item.name); $li.appendChild($playButton); $li.appendChild($spacer); $li.appendChild($text); $ul.appendChild($li); }); document.body.appendChild($ul); })(); //# sourceMappingURL=demo.js.map