Text to speech function

Custom Code

Im trying to setup a text to speech function and I've added the flutter tts dependency and the custom action with code below, but when I assign the code to a button, it doesnt do anything. Fairly new to coding so any help is appreciated.

import 'package:flutter_tts/flutter_tts.dart';

Future speakText(String text) async {
  FlutterTts flutterTts = FlutterTts();
  await flutterTts.setLanguage("en-US");
  await flutterTts.setPitch(1.0);
  await flutterTts.speak(text);
  text = "hello";
}
What have you tried so far?

As you can see in the code Ive tried to just get it to say hello but still doesnt work. Not sure what else to do

Did you check FlutterFlow's Documentation for this topic?
No
2
4 replies