This commit is contained in:
Hamza-Ayed
2024-02-06 10:43:14 +03:00
parent a34c2d9eda
commit 4ee10218a9
9 changed files with 110 additions and 10 deletions

View File

@@ -0,0 +1,25 @@
import 'package:flutter_tts/flutter_tts.dart';
class TextToSpeech {
final FlutterTts tts = FlutterTts();
// Initialize the TTS engine with desired settings
Future initTts() async {
await tts.setLanguage('en-US'); // Set language
await tts.setSpeechRate(0.8); // Adjust speech rate
await tts.setVolume(1.0); // Set volume
}
// Speak the given text
Future speakText(String text) async {
await tts.speak(text);
}
// Stop speaking
Future stopSpeaking() async {
await tts.stop();
}
// Check if TTS is currently speaking
// bool isSpeaking() => tts.isSpeaking;
}