javascript - 世博会文字转语音无法在 iPhone 7 上运行
问题描述
我有以下使用 Expo SDK 的反应本机代码。我正在我的 iphone 7 上对此进行测试。文本到语音部分根本不起作用。如何解决这个问题?github上有一个类似的问题是开放的。
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',
},
});
解决方案
推荐阅读
- reactjs - 如何摆脱这个 - 消息:{'你没有订阅这个 API。'}。?
- php - Symfony 5 控制器不会验证错误
- javascript - 正确添加元素到 React Native 中的对象数组
- javascript - 将变量添加到 ajax 中的新 FormData 对象的问题
- nebular - 如何更改 NbSuffix/NbPrefix 的颜色
- python - Seaborn Catplot 误差与分类预测变量
- c# - UWP Webview - 选项卡标题更改时触发事件(DocumentTitle)
- pytest - 在 Windows 10 终端中使用 py.test 命令出错
- javascript - 每次修改单元格时创建/更改日期戳
- python - 如何在 map 方法中预处理和标记 TensorFlow CsvDataset?