Frage

The following Dart code does not work on Chrome or Firefox.

import 'dart:html';

void main() {
  SpeechSynthesisUtterance speechSynthesisUtterance = new SpeechSynthesisUtterance();
  speechSynthesisUtterance.lang = 'en-US';
  speechSynthesisUtterance.rate = 1;

  DivElement div = querySelector("#text");
  querySelector('#read').onClick.listen((e) {
    speechSynthesisUtterance.text = div.text;
    window.speechSynthesis.speak(speechSynthesisUtterance);
  });

}

The browser's console displays this error:

Uncaught ReferenceError: SpeechSynthesisUtterance is not defined 

This was tested on: Chromium Version (31.0.1650.63) & Firefox (26.0) on Ubuntu 13.10 x64

Any idea what is going wrong?

War es hilfreich?

Lösung

This is not a Dart-specific problem. If you try the equivalent JavaScript it will also not work in those browsers since this API does not seem to be fully supported yet. It does work in Dartium though.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top