flutter_text_to_speech 1.0.0 copy "flutter_text_to_speech: ^1.0.0" to clipboard
flutter_text_to_speech: ^1.0.0 copied to clipboard

outdated

Text to Speech. This plugin is supported on both IOS and Android.

Text To Speech #

pub package

A flutter text to speech plugin (Swift,Java)

Features #

  • ✅ Android & iOS
    • ✅ speak
    • ✅ stop
    • ✅ get languages
    • ✅ set language
    • ✅ is language available
    • ✅ set speech rate
    • ✅ set speech volume
    • ✅ set speech pitch
  • ✅ Android
    • ✅ get voices
    • ✅ set voice

Usage #

Android #

Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file.

minSdkVersion 21

iOS #

There's a known issue with integrating plugins that use Swift into a Flutter project created with the Objective-C template. Flutter#16049

Example

To use this plugin :

  dependencies:
    flutter:
      sdk: flutter
    flutter_tts:
  • instantiate a FlutterTts instance
FlutterTts flutterTts = new FlutterTts();

speak, stop, getLanguages, setLanguage, setSpeechRate, setVolume, setPitch, isLanguageAvailable #

Future _speak() async{
    var result = await flutterTts.speak("Hello World");
    if (result == 1) setState(() => ttsState = TtsState.playing);
}

Future _stop() async{
    var result = await flutterTts.stop();
    if (result == 1) setState(() => ttsState = TtsState.stopped);
}

List<dynamic> languages = await flutterTts.getLanguages;

await flutterTts.setLanguage("en-US");

await flutterTts.setSpeechRate(1.0);

await flutterTts.setVolume(1.0);

await flutterTts.setPitch(1.0);

await flutterTts.isLanguageAvailable("en-US");

Listening for platform calls #

flutterTts.setStartHandler(() {
  setState(() {
    ttsState = TtsState.playing;
  });
});

flutterTts.setCompletionHandler(() {
  setState(() {
    ttsState = TtsState.stopped;
  });
});

flutterTts.setErrorHandler((msg) {
  setState(() {
    ttsState = TtsState.stopped;
  });
});

Getting Started #

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

11
likes
30
pub points
54%
popularity

Publisher

verified publisherrishabnayak.com

Text to Speech. This plugin is supported on both IOS and Android.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_text_to_speech