UNPKG

@huluvu424242/honey-speech

Version:

Text to Speech component wich is reading texts from DOM elements.

24 lines (23 loc) 638 B
import { Logger } from "./logger"; export class Synthese { constructor() { this.sprachSynthese = window.speechSynthesis; this.sprachSynthese.onvoiceschanged = () => { if (!this.voices || this.voices.length < 1) { this.voices = this.sprachSynthese.getVoices(); Logger.debugMessage("voices changed to: " + this.voices.join(",")); } else { Logger.debugMessage("voices alraedy initialized"); } }; Logger.debugMessage("call getVoices()"); this.sprachSynthese.getVoices(); } getVoices() { return this.voices; } cancel() { this.sprachSynthese.cancel(); } }