linux_tts 0.1.0
linux_tts: ^0.1.0 copied to clipboard
Offline, on-device text-to-speech for embedded Linux via spd-say (speech-dispatcher). Pure Dart, no Flutter dependency. Degrades silently when the speech backend is absent.
example/linux_tts_example.dart
// Minimal example: speak a navigation prompt on Linux if speech-dispatcher
// is available, otherwise degrade gracefully.
import 'package:linux_tts/linux_tts.dart';
Future<void> main() async {
final TtsEngine engine = LinuxTtsEngine();
if (!await engine.isAvailable()) {
// No speech-dispatcher backend on this machine. In a real app, fall back
// to a visual cue, or call (engine as LinuxTtsEngine).ensureAvailable()
// to throw TtsUnavailableException where speech is mandatory.
return;
}
await engine.setLanguage('ja-JP');
await engine.setVolume(0.8);
await engine.setSpeechRate(0.9);
await engine.speak('まもなく右折です。');
await Future<void>.delayed(const Duration(seconds: 2));
await engine.stop();
await engine.dispose();
}