2/6/3
This commit is contained in:
25
lib/controller/functions/tts.dart
Normal file
25
lib/controller/functions/tts.dart
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user