笔者在以前这篇文章中ReactNative集成百度语音合成介绍了在项目中如何集成百度语音合成步骤和部分代码。
今天重(you)磅(dian)推(peng)出(zhang)百度语音合成开源库# react-native-baidu-vtts ,目前只作了Android端的集成,后期补上IOS端集成,开源不易,欢迎你们starreact
请参考ReactNative集成百度语音合成的“兵马未动粮草先行”模块git
npm install react-native-baidu-vtts --save or yarn add react-native-baidu-vtts 自动添加原生依赖 react-native link 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 String appid = '' const String apikey = '' const String 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> ); } }
同步更新至我的网站:https://wayne214.github.io
欢迎关注个人公众号:君伟说, 一个有温度的公众号。github