expo text to speech not working on iphone 7

Viewed 134

I have the following react native code that uses Expo SDK. I am testing this on my iphone 7. The text to speech part does not work at all. How to resolve this ? There is a similar issue on github which is open.

Github Issue

import React from 'react';
import { StyleSheet, Text, View,Button } from 'react-native';
import * as Speech from 'expo-speech';

export default class App extends React.Component {

  constructor(props)
  {
    super(props)
    this.state={word:""}
  }

  async readFile(){
    fetch("https://random-word-api.herokuapp.com/word?number=1")
    .then((response)=>response.json())
    .then((response)=>{this.setState({word:response[0]})})

  }

  componentDidMount(){
    this.readFile()
  }

  speak(){
    console.log("WORD IS "+this.state.word)
    Speech.speak(this.state.word)
  }

  render(){
  return (
    <View style={styles.container}>
      <Text>{this.state.word}</Text>
      <Button title="ANOTHER WORD" onPress={()=>this.readFile()}></Button>
      <Button title="SPEAK" onPress={()=>this.speak()}></Button>
    </View>
  );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});
0 Answers
Related