initTextToSpeech method

Future<void> initTextToSpeech()

Implementation

Future<void> initTextToSpeech() async {
  await flutterTts.setLanguage("en-IN");
  Fimber.d("${(await flutterTts.getVoices)}");
  await flutterTts.setVoice(Platform.isAndroid
      ? {"name": "en-us-x-tpf-local", "locale": "en-US"}
      : {
          "identifier": "com.apple.ttsbundle.siri_Nicky_en-US_compact",
          "name": "Nicky",
          "locale": "en-US",
          "gender": "female",
          "quality": "default"
        });
  await flutterTts.setSpeechRate(0.5);
  await flutterTts.setVolume(1.0);
  await flutterTts.setPitch(1.0);

  await flutterTts.setIosAudioCategory(IosTextToSpeechAudioCategory.playback,
      [IosTextToSpeechAudioCategoryOptions.defaultToSpeaker]);

  flutterTts.setCompletionHandler(() {
    stopReading();
  });
  flutterTts.setCancelHandler(() {
    stopReading();
  });
}