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;
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:math' show cos;
|
import 'dart:math' show cos;
|
||||||
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -1461,6 +1463,8 @@ class MapPassengerController extends GetxController {
|
|||||||
//print(nearestCar!.id);
|
//print(nearestCar!.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<double> headingAngles = [];
|
||||||
|
|
||||||
late LatLngBounds boundsData;
|
late LatLngBounds boundsData;
|
||||||
getMap(String origin, destination) async {
|
getMap(String origin, destination) async {
|
||||||
await getCarsLocationByPassenger();
|
await getCarsLocationByPassenger();
|
||||||
@@ -1510,7 +1514,23 @@ class MapPassengerController extends GetxController {
|
|||||||
double distanceOfTrip = (data[0]['distance']['value']) / 1000;
|
double distanceOfTrip = (data[0]['distance']['value']) / 1000;
|
||||||
distance = distanceOfTrip;
|
distance = distanceOfTrip;
|
||||||
// updateCameraForDistanceAfterGetMap();
|
// updateCameraForDistanceAfterGetMap();
|
||||||
|
for (var step in data[0]['steps']) {
|
||||||
|
var startLat = step['start_location']['lat'];
|
||||||
|
var startLng = step['start_location']['lng'];
|
||||||
|
|
||||||
|
var endLat = step['end_location']['lat'];
|
||||||
|
var endLng = step['end_location']['lng'];
|
||||||
|
|
||||||
|
// Calculate heading
|
||||||
|
var y = math.sin(endLng - startLng) * math.cos(endLat);
|
||||||
|
var x = math.cos(startLat) * math.sin(endLat) -
|
||||||
|
math.sin(startLat) * math.cos(endLat) * math.cos(endLng - startLng);
|
||||||
|
var theta = math.atan2(y, x);
|
||||||
|
|
||||||
|
// Add to list
|
||||||
|
headingAngles.add(theta);
|
||||||
|
}
|
||||||
|
print(headingAngles);
|
||||||
if (polyLines.isNotEmpty) {
|
if (polyLines.isNotEmpty) {
|
||||||
clearPolyline();
|
clearPolyline();
|
||||||
} else {
|
} else {
|
||||||
@@ -1851,6 +1871,15 @@ class MapPassengerController extends GetxController {
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initilizeGetStorage() {
|
||||||
|
if (box.read(BoxName.addWork).toString() == '') {
|
||||||
|
box.write(BoxName.addWork, 'addWork');
|
||||||
|
}
|
||||||
|
if (box.read(BoxName.addHome).toString() == '') {
|
||||||
|
box.write(BoxName.addHome, 'addHome');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() async {
|
void onInit() async {
|
||||||
mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
|
mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
|
||||||
@@ -1865,6 +1894,7 @@ class MapPassengerController extends GetxController {
|
|||||||
addCustomStartIcon();
|
addCustomStartIcon();
|
||||||
addCustomEndIcon();
|
addCustomEndIcon();
|
||||||
startMarkerReloading();
|
startMarkerReloading();
|
||||||
|
initilizeGetStorage();
|
||||||
cardNumber = await SecureStorage().readData(BoxName.cardNumber);
|
cardNumber = await SecureStorage().readData(BoxName.cardNumber);
|
||||||
|
|
||||||
super.onInit();
|
super.onInit();
|
||||||
|
|||||||
@@ -207,8 +207,13 @@ GetBuilder<MapPassengerController> formSearchPlacesDestenation() {
|
|||||||
controller.changePickerShown();
|
controller.changePickerShown();
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Container(
|
||||||
'Work : ${box.read(BoxName.addWork) == 'addWork' ? 'Add Work' : box.read(BoxName.addWork).toString().split(',')[0] + box.read(BoxName.addWork).toString().split(',')[1]} '),
|
decoration: BoxDecoration(
|
||||||
|
color: AppColor.greenColor.withOpacity(.4),
|
||||||
|
border: Border.all()),
|
||||||
|
child: Text(
|
||||||
|
'Work : ${box.read(BoxName.addWork) == 'addWork' ? 'Add Work' : box.read(BoxName.addWork).toString().split(',')[0] + box.read(BoxName.addWork).toString().split(',')[1]} '),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
InkWell(
|
InkWell(
|
||||||
onLongPress: () {
|
onLongPress: () {
|
||||||
@@ -243,8 +248,13 @@ GetBuilder<MapPassengerController> formSearchPlacesDestenation() {
|
|||||||
controller.update();
|
controller.update();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Container(
|
||||||
'Home : ${box.read(BoxName.addHome) == 'addHome' ? 'Add Home' : box.read(BoxName.addHome)} '),
|
decoration: BoxDecoration(
|
||||||
|
color: AppColor.yellowColor.withOpacity(.4),
|
||||||
|
border: Border.all()),
|
||||||
|
child: Text(
|
||||||
|
'Home : ${box.read(BoxName.addHome) == 'addHome' ? 'Add Home' : box.read(BoxName.addHome)} '),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
|
|
||||||
import '../../../constant/colors.dart';
|
import '../../../constant/colors.dart';
|
||||||
|
import '../../../controller/functions/tts.dart';
|
||||||
import '../../../controller/home/map_passenger_controller.dart';
|
import '../../../controller/home/map_passenger_controller.dart';
|
||||||
|
|
||||||
GetBuilder<MapPassengerController> leftMainMenuIcons() {
|
GetBuilder<MapPassengerController> leftMainMenuIcons() {
|
||||||
@@ -56,7 +57,27 @@ GetBuilder<MapPassengerController> leftMainMenuIcons() {
|
|||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 5,
|
height: 5,
|
||||||
),
|
),
|
||||||
// if (Platform.isIOS)
|
if (Platform.isIOS)
|
||||||
|
AnimatedContainer(
|
||||||
|
duration: const Duration(microseconds: 200),
|
||||||
|
width: controller.widthMapTypeAndTraffic,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColor.secondaryColor,
|
||||||
|
border: Border.all(),
|
||||||
|
borderRadius: BorderRadius.circular(15)),
|
||||||
|
child: IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
controller.mapController?.animateCamera(
|
||||||
|
CameraUpdate.newLatLng(LatLng(
|
||||||
|
controller.passengerLocation.latitude,
|
||||||
|
controller.passengerLocation.longitude)));
|
||||||
|
},
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.location_on,
|
||||||
|
size: 29,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
AnimatedContainer(
|
AnimatedContainer(
|
||||||
duration: const Duration(microseconds: 200),
|
duration: const Duration(microseconds: 200),
|
||||||
width: controller.widthMapTypeAndTraffic,
|
width: controller.widthMapTypeAndTraffic,
|
||||||
@@ -66,13 +87,12 @@ GetBuilder<MapPassengerController> leftMainMenuIcons() {
|
|||||||
borderRadius: BorderRadius.circular(15)),
|
borderRadius: BorderRadius.circular(15)),
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
controller.mapController?.animateCamera(
|
final _textToSpeech = TextToSpeech();
|
||||||
CameraUpdate.newLatLng(LatLng(
|
_textToSpeech.initTts();
|
||||||
controller.passengerLocation.latitude,
|
_textToSpeech.speakText("Hello, world!");
|
||||||
controller.passengerLocation.longitude)));
|
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.location_on,
|
Icons.voice_chat,
|
||||||
size: 29,
|
size: 29,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import firebase_core
|
|||||||
import firebase_messaging
|
import firebase_messaging
|
||||||
import flutter_local_notifications
|
import flutter_local_notifications
|
||||||
import flutter_secure_storage_macos
|
import flutter_secure_storage_macos
|
||||||
|
import flutter_tts
|
||||||
import geolocator_apple
|
import geolocator_apple
|
||||||
import iris_method_channel
|
import iris_method_channel
|
||||||
import just_audio
|
import just_audio
|
||||||
@@ -33,6 +34,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
|||||||
FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin"))
|
FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin"))
|
||||||
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
|
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
|
||||||
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
||||||
|
FlutterTtsPlugin.register(with: registry.registrar(forPlugin: "FlutterTtsPlugin"))
|
||||||
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
|
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
|
||||||
IrisMethodChannelPlugin.register(with: registry.registrar(forPlugin: "IrisMethodChannelPlugin"))
|
IrisMethodChannelPlugin.register(with: registry.registrar(forPlugin: "IrisMethodChannelPlugin"))
|
||||||
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
|
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
|
||||||
|
|||||||
@@ -659,6 +659,14 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_tts:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_tts
|
||||||
|
sha256: cbb3fd43b946e62398560235469e6113e4fe26c40eab1b7cb5e7c417503fb3a8
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.8.5"
|
||||||
flutter_web_plugins:
|
flutter_web_plugins:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ dependencies:
|
|||||||
calendar_builder: ^0.0.6
|
calendar_builder: ^0.0.6
|
||||||
fl_chart: ^0.66.0
|
fl_chart: ^0.66.0
|
||||||
agora_rtc_engine: ^6.2.6
|
agora_rtc_engine: ^6.2.6
|
||||||
|
flutter_tts: ^3.8.5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <file_selector_windows/file_selector_windows.h>
|
#include <file_selector_windows/file_selector_windows.h>
|
||||||
#include <firebase_core/firebase_core_plugin_c_api.h>
|
#include <firebase_core/firebase_core_plugin_c_api.h>
|
||||||
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
||||||
|
#include <flutter_tts/flutter_tts_plugin.h>
|
||||||
#include <geolocator_windows/geolocator_windows.h>
|
#include <geolocator_windows/geolocator_windows.h>
|
||||||
#include <iris_method_channel/iris_method_channel_plugin_c_api.h>
|
#include <iris_method_channel/iris_method_channel_plugin_c_api.h>
|
||||||
#include <local_auth_windows/local_auth_plugin.h>
|
#include <local_auth_windows/local_auth_plugin.h>
|
||||||
@@ -24,6 +25,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
|||||||
registry->GetRegistrarForPlugin("FirebaseCorePluginCApi"));
|
registry->GetRegistrarForPlugin("FirebaseCorePluginCApi"));
|
||||||
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
|
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
|
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
|
||||||
|
FlutterTtsPluginRegisterWithRegistrar(
|
||||||
|
registry->GetRegistrarForPlugin("FlutterTtsPlugin"));
|
||||||
GeolocatorWindowsRegisterWithRegistrar(
|
GeolocatorWindowsRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("GeolocatorWindows"));
|
registry->GetRegistrarForPlugin("GeolocatorWindows"));
|
||||||
IrisMethodChannelPluginCApiRegisterWithRegistrar(
|
IrisMethodChannelPluginCApiRegisterWithRegistrar(
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
|||||||
file_selector_windows
|
file_selector_windows
|
||||||
firebase_core
|
firebase_core
|
||||||
flutter_secure_storage_windows
|
flutter_secure_storage_windows
|
||||||
|
flutter_tts
|
||||||
geolocator_windows
|
geolocator_windows
|
||||||
iris_method_channel
|
iris_method_channel
|
||||||
local_auth_windows
|
local_auth_windows
|
||||||
|
|||||||
Reference in New Issue
Block a user