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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top