Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top