ReactNative集成百度语音合成SDK的组件



  • 分享一个自己封装开源的的集成百度语音合成SDK的组件,react-native-baidu-vtts,目前只集成了Android端,IOS端很快就来,敬请期待。 欢迎大家star

    安装:

    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>
            );
        }
    }
    

Log in to reply