diff --git a/client/package-lock.json b/client/package-lock.json index 6d3dfbd..364665c 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -18,6 +18,7 @@ "deg2rad": "^1.0.0", "expo": "^52.0.7", "expo-location": "^18.0.2", + "expo-speech": "~13.0.1", "expo-status-bar": "~2.0.0", "react": "^18.3.1", "react-dom": "^18.3.1", @@ -9191,6 +9192,15 @@ "invariant": "^2.2.4" } }, + "node_modules/expo-speech": { + "version": "13.0.1", + "resolved": "https://registry.npmjs.org/expo-speech/-/expo-speech-13.0.1.tgz", + "integrity": "sha512-J7tvFzORsFpIKihMnayeY5lCPc15giDrlN+ws2uUNo0MvLv1HCYEu/5p3+aMmZXXsY5I1QlconD4CwRWw3JFig==", + "license": "MIT", + "peerDependencies": { + "expo": "*" + } + }, "node_modules/expo-status-bar": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/expo-status-bar/-/expo-status-bar-2.0.0.tgz", diff --git a/client/package.json b/client/package.json index 3cb41ad..f4fb30d 100644 --- a/client/package.json +++ b/client/package.json @@ -39,7 +39,8 @@ "react-native-safe-area-context": "4.12.0", "react-native-screens": "~4.0.0", "react-native-svg": "15.8.0", - "react-native-websocket": "^1.0.2" + "react-native-websocket": "^1.0.2", + "expo-speech": "~13.0.1" }, "devDependencies": { "@babel/core": "^7.26.9", diff --git a/client/src/DisplayRoute.js b/client/src/DisplayRoute.js index ce9d897..c981418 100644 --- a/client/src/DisplayRoute.js +++ b/client/src/DisplayRoute.js @@ -2,12 +2,14 @@ import React, { useEffect, useState, useCallback } from 'react'; import { View, Text, Alert, TouchableOpacity, Switch } from 'react-native'; +import * as Speech from 'expo-speech'; import MapView, { Polyline, Marker } from 'react-native-maps'; import { haversine, startLocationTracking } from './utils/mapUtils'; import displayRouteStyles from './components/styles/DisplayRoute.styles'; import locationCircleIcon from './assets/location-circle.png'; + export default function DisplayRouteScreen({ navigation, route }) { // route is a prop passed by the navigator, hence why that is used instead of other variable names const { origin, destination, routeData, polylineCoordinates } = route.params; @@ -53,6 +55,10 @@ export default function DisplayRouteScreen({ navigation, route }) { }; }, [devMode, checkProximityAndUpdate]); + useEffect(() => { + Speech.speak(currentInstruction); + }, [currentInstruction]); + function removeHtmlTags(instruction) { return instruction.replace(/<\/?[^>]+(>|$)/g, ''); }