Nawaf Alsulami
Nawaf Alsulami

Reputation: 719

How to use Dart SpeechSynthesis class?

I'm unable to construct a SpeechSynthesis object using Dart SpeechSynthesis class. Dart editor complains: "The class 'SpeechSynthesis' does not have a default constructor".

Upvotes: 2

Views: 370

Answers (1)

Alexandre Ardhuin
Alexandre Ardhuin

Reputation: 76183

Here's a working example :

import 'dart:html';
main() {
  var u = new SpeechSynthesisUtterance();
  u.text = 'Hello World';
  u.lang = 'en-US';
  u.rate = 1.2;
  window.speechSynthesis.speak(u);
}

See the SpeechSynthesis Interface for more details on the API.

Upvotes: 2

Related Questions