stts 1.2.4
stts: ^1.2.4 copied to clipboard
Speech-to-Text and Text-to-Speech plugin. Offline first.
stts #
Speech-to-Text (STT) and Text-to-Speech (TTS) Flutter plugin.
No dependency. All implementations use what the platform provides.
Platform Speech-to-Text parity matrix #
Feature | Android | iOS | macOS | web | Windows |
---|---|---|---|---|---|
permission | ✔️ | ✔️ | ✔️ | ✔️ | |
language selection | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
punctuation | ✔️ | ✔️ | ✔️ | ||
grammars | ✔️* | ✔️ | ✔️ | ✔️* |
- *: seems to do nothing.
- Specific platform features are not listed here.
Platform Text-to-Speech parity matrix #
Feature | Android | iOS | macOS | web | Windows |
---|---|---|---|---|---|
pause/resume | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
language selection | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
voice selection | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
pitch | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
rate | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
volume | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Usage of Speech-to-Text #
import 'package:stts/stts.dart';
final stt = Stt();
// Get state changes
final sub = stt.onStateChanged.listen(
(speechState) { /* SttState.start/stop */ },
onError: (err) {/* Retrieve listener errors from here */ },
);
await tts.hasPermission(); // Request for audio recording and STT service usage.
// Get intermediate and final results.
stt.onResultChanged.listen((result) { /* The current result String */ });
// Start speech recognition.
stt.start(); // ...optionnaly, abort with stt.stop();
// As always, don't forget to release resources.
sub.cancel();
stt.dispose();
Usage of Text-to-Speech #
import 'package:stts/stts.dart';
final tts = Tts();
// Get state changes
final sub = tts.onStateChanged.listen(
(ttsState) { /* TtsState.start/stop/pause */ },
onError: (err) { /* Retrieve listener errors from here */ },
);
// Add utterance. Texts are queued.
tts.start('Hello');
tts.start('world!'); // ...optionnaly, abort with tts.stop();
// As always, don't forget to release resources.
sub.cancel();
tts.dispose();
Platforms setup & infos #
You can either use one or both engines in your app. So permissions are only required for dedicated engine.
Misc. infos / warnings #
- Speech recognition is time limited. You can't use it to fill very long texts in a single session.
- Speech recognition will auto stop, when detecting silence.
- This plugin is offline first, this can't be guaranteed.