代码拉取完成,页面将自动刷新
This is an React-native library that can do text-to-speech
please follow this page ReactNative集成百度语音合成 make setting.
current is only support android, ios coming soon.
$ npm install react-native-baidu-vtts --save
$ react-native link react-native-baidu-vtts
coming soon
android/app/src/main/java/[...]/MainActivity.java
import com.wayne.baiduvoice.RNBaiduvoicePackage;
to the imports at the top of the filenew RNBaiduvoicePackage()
to the list returned by the getPackages()
methodandroid/settings.gradle
:
include ':react-native-baidu-vtts'
project(':react-native-baidu-vtts').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-baidu-vtts/android')
android/app/build.gradle
:
implementation project(':react-native-baidu-vtts')
import RNBaiduvoice from 'react-native-baidu-vtts';
// TODO: What to do with the module?
class App extends Component{
componentDidMount() {
// 填写百度语音官网申请的appid, apikey, secretkey
const appid = ''
const apikey = ''
const secretkey = ''
RNBaiduvoice.initBaiduTTS(appid,apikey,secretkey)
}
_speechText = () => {
RNBaiduvoice.speak('百度语音')
}
render() {
return (
<View style={styles.container}>
{/*<TwoList/>*/}
<TouchableOpacity onPress={this._speechText}>
<Text style={{fontSize: 20, height: 30}}>测试语音</Text>
</TouchableOpacity>
</View>
);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。