I created a custom action that will do text to speech:
import 'package:flutter_tts/flutter_tts.dart';
Future talkToMe(String text) async {
// Create a tts object
FlutterTts flutterTts = FlutterTts();
// Set properties
flutterTts.setLanguage("en-US");
flutterTts.setVoice({"name": "Karen", "locale": "en-AU"});
flutterTts.setSpeechRate(1.0);
flutterTts.setPitch(1); // 0.5 - 1.5
// Speak
flutterTts.speak(text);
}
In addition to this, as the app is reading the text, I want to be able to track details about where in the text it is at any time. My understanding is, I need a "Handler" to do this. Here is an excerpt of code that I pulled off some website for a handler:
flutterTts.setProgressHandler((text, start, end, word) {
print("TEXT HANDLED = " + word);
});
I guess all this handler does, is print each word in the text, at the time it is being spoken.
Where in flutterflow would I put this handler? I don't think it belongs inside my text to speech function, I think it needs to be outside of it. I thought I might create it as a custom action, and add it as an initial action in the "main.dart" file, but that doesn't allow you to add actions with with parameters.
Anyone have ideas?