4 Best Text-to-Speech and Speech-to-Text Libraries for Flutter

These Flutter Text-to-Speech libraries will allow developers to bring TTS feature to their apps easily.

flutter_tts

flutter_tts is a plugin for Text to Speech. It supports many platforms, including iOS, Android, Web, & macOS.

FlutterTts flutterTts = FlutterTts();
Future _speak() async{
    var result = await flutterTts.speak("My first word");
    if (result == 1) setState(() => ttsState = TtsState.playing);
}

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

flutter_tts_improved

This is a fork of the flutter_tts plugin. It uses the progress reporters of the Utterance APIs, on both Android and iOS.

FlutterTtsImproved tts = new FlutterTtsImproved();
Future _speak() async{
    var result = await tts.speak("My first word");
    if (result == 1) setState(() => ttsState = TtsState.playing);
}

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

aws_polly

This plugin is an unofficial AWS Polly client for Dart and Flutter. AWS Polly is an Amazon cloud service that converts text into lifelike speech.aws_polly is a simple wrapper for this service.

It allows to generate a URL given an input text and voice identifier. You must have an AWS account and enable this service to use this package.

Create a client using your new poolId and region:

final AwsPolly _awsPolly = AwsPolly.instance(
    poolId: 'us-east-1:xxxx-xxx-xxxxx',
    region: AWSRegionType.USEast1,
);

Generate a new URL:

final url = await _awsPolly.getUrl(
    voiceId: AWSPolyVoiceId.nicole,
    input: 'Please convert this text to speech!',
);

speech_to_text

This plugin contains a set of classes that make it easy to use the speech recognition features.

import 'package:speech_to_text/speech_to_text.dart' as stt;

stt.SpeechToText speech = stt.SpeechToText();

bool available = await speech.initialize( onStatus: statusListener, onError: errorListener );
if ( available ) {
    speech.listen( onResult: resultListener );
}
else {
    print("Speech recognition is not allowed on this device.");
}

//stop speech
speech.stop()

Leave a Comment

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close