SpeechSynthesisErrorEvent
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since Oktober 2018.
Die SpeechSynthesisErrorEvent-Schnittstelle der Web Speech API enthält Informationen über Fehler, die bei der Verarbeitung von SpeechSynthesisUtterance-Objekten im Sprachdienst auftreten.
Konstruktor
SpeechSynthesisErrorEvent()-
Erstellt ein neues
SpeechSynthesisErrorEvent.
Instanz-Eigenschaften
SpeechSynthesisErrorEvent erweitert die SpeechSynthesisEvent-Schnittstelle, die Eigenschaften von ihrer Elternschnittstelle, Event, erbt.
SpeechSynthesisErrorEvent.errorSchreibgeschützt-
Gibt einen Fehlercode zurück, der angibt, was bei einem Sprachsyntheseversuch schiefgelaufen ist.
Instanz-Methoden
SpeechSynthesisErrorEvent erweitert die SpeechSynthesisEvent-Schnittstelle, die Methoden von ihrer Elternschnittstelle, Event, erbt.
Beispiele
js
const synth = window.speechSynthesis; const inputForm = document.querySelector("form"); const inputTxt = document.querySelector("input"); const voiceSelect = document.querySelector("select"); const voices = synth.getVoices(); // … inputForm.onsubmit = (event) => { event.preventDefault(); const utterThis = new SpeechSynthesisUtterance(inputTxt.value); const selectedOption = voiceSelect.selectedOptions[0].getAttribute("data-name"); for (const voice of voices) { if (voice.name === selectedOption) { utterThis.voice = voice; } } synth.speak(utterThis); utterThis.onerror = (event) => { console.log( `An error has occurred with the speech synthesis: ${event.error}`, ); }; inputTxt.blur(); }; Spezifikationen
| Specification |
|---|
| Web Speech API> # speechsynthesiserrorevent> |