I can’t get iOS simulator or my iPhone to narrate the text on iOS
here is a summary of my code:
'import React, {useStat } from 'react';
import { View, Text, StyleSheet, ScrollView, Image, Dimensions, Pressable
} from 'react-native';
import { AntDesign } from '@expo/vector-icons';
import * as Speech from 'expo-speech';
const { width } = Dimensions.get('window');
const screenWidthMinus50 = (width) - 50;
const App = () => {
const [isNarrating, setIsNarrating] = useState(false);
const toggleNarration = () => {
if (isNarrating) {
Speech.stop();
} else {
narrateTextElements();
}
setIsNarrating(!isNarrating);
};
const narrateTextElements = () => {
const textElements = [
"Test text"
];
const textToNarrate = textElements.join('. ');
Speech.speak(textToNarrate, {
rate: 1.0,
pitch: 1.0,
language: 'en-AU'
});
};
return (
<ScrollView contentContainerStyle={styles.container}>
<Pressable onPress={toggleNarration}>
<AntDesign name="playcircleo" size={18} color={isNarrating ? 'blue' :
'black'} />
</Pressable>
<Text style={styles.description}>
Test text
</Text>
</ScrollView>
);
};
const styles = StyleSheet.create({
container: {
flexGrow: 1,
padding: 20,
alignItems: 'center',
},
image: {
width: screenWidthMinus50,
height: screenWidthMinus50,
resizeMode: 'cover',
marginBottom: 10,
},
description: {
fontSize: 16,
lineHeight: 24,
},
});
export default App;
'
tried useEffect with expo-av. with no success. I tried running an MP3 prior to the text-to-speech with no effect. I still can’t get the text to be read in my app. it seems like it’s an iOS specific problem. I also toggled silent and non silent mode with no effect
New contributor
user24727039 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.