2/6/4
This commit is contained in:
@@ -1,25 +1,38 @@
|
||||
import 'package:flutter_tts/flutter_tts.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class TextToSpeech {
|
||||
final FlutterTts tts = FlutterTts();
|
||||
class TextToSpeechController extends GetxController {
|
||||
final flutterTts = 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
|
||||
// Initialize TTS in initState
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
initTts();
|
||||
}
|
||||
|
||||
// Speak the given text
|
||||
Future speakText(String text) async {
|
||||
await tts.speak(text);
|
||||
// Dispose of TTS when controller is closed
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
flutterTts.completionHandler;
|
||||
}
|
||||
|
||||
// Stop speaking
|
||||
Future stopSpeaking() async {
|
||||
await tts.stop();
|
||||
// Function to initialize TTS engine
|
||||
Future<void> initTts() async {
|
||||
await flutterTts.setLanguage('en-US'); // Set language
|
||||
await flutterTts.setSpeechRate(0.5); // Adjust speech rate
|
||||
await flutterTts.setVolume(1.0); // Set volume
|
||||
}
|
||||
|
||||
// Check if TTS is currently speaking
|
||||
// bool isSpeaking() => tts.isSpeaking;
|
||||
// Function to speak the given text
|
||||
Future<void> speakText(String text) async {
|
||||
try {
|
||||
await flutterTts.speak(text);
|
||||
} catch (error) {
|
||||
// Handle error gracefully, e.g., show a message
|
||||
Get.snackbar('Error', 'Failed to speak text: $error');
|
||||
print('Failed to speak text: $error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import '../../constant/info.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../../main.dart';
|
||||
import '../../models/model/locations.dart';
|
||||
import '../../views/Rate/rate_captain.dart';
|
||||
import '../../views/widgets/elevated_btn.dart';
|
||||
import '../firebase/firbase_messge.dart';
|
||||
import '../functions/crud.dart';
|
||||
@@ -166,7 +165,7 @@ class MapPassengerController extends GetxController {
|
||||
List<String> hintTextwayPointStringAll = [];
|
||||
var placesCoordinate = <String>[];
|
||||
String hintTextDestinationPoint = 'Select your destination'.tr;
|
||||
late String rideId;
|
||||
late String rideId = 'yet';
|
||||
bool noCarString = false;
|
||||
bool isCashSelectedBeforeConfirmRide = false;
|
||||
bool isPassengerChosen = false;
|
||||
@@ -953,7 +952,7 @@ class MapPassengerController extends GetxController {
|
||||
isMarkersShown = false;
|
||||
// totalStepDurations = 0;
|
||||
timeToPassengerFromDriverAfterApplied = 0;
|
||||
if (rideId != '') {
|
||||
if (rideId != 'yet') {
|
||||
await CRUD().post(link: AppLink.updateDriverOrder, payload: {
|
||||
"order_id": rideId.toString(), // Convert to String
|
||||
"status": 'Cancel'
|
||||
@@ -1267,7 +1266,7 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
|
||||
// Configure location accuracy
|
||||
LocationAccuracy desiredAccuracy = LocationAccuracy.high;
|
||||
// LocationAccuracy desiredAccuracy = LocationAccuracy.high;
|
||||
|
||||
// Get the current location
|
||||
LocationData _locationData = await location.getLocation();
|
||||
@@ -1871,18 +1870,18 @@ class MapPassengerController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
initilizeGetStorage() {
|
||||
if (box.read(BoxName.addWork).toString() == '') {
|
||||
initilizeGetStorage() async {
|
||||
if (box.read(BoxName.addWork) == null) {
|
||||
box.write(BoxName.addWork, 'addWork');
|
||||
}
|
||||
if (box.read(BoxName.addHome).toString() == '') {
|
||||
if (box.read(BoxName.addHome) == null) {
|
||||
box.write(BoxName.addHome, 'addHome');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
|
||||
// mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
|
||||
readyWayPoints();
|
||||
await getLocation();
|
||||
await addToken();
|
||||
|
||||
Reference in New Issue
Block a user