Skip to content
JoaoCnh edited this page Jan 20, 2016 · 4 revisions

#DOCS


react-native-android-voice is a React Native module for the Android platform. Its focus is on providing an easy way of incorporating the Speech-To-Text functionality in your apps.

#v0.1.1

##Example Usage

Let's say we create a new example app with react-native init VoiceTest.

A way we could start using this module easily is by simply importing it

import SpeechAndroid from 'react-native-android-voice';

and afterwards call the startSpeech method on a click of a button for example.

class SpeechTest extends Component {    
    async _onPressButton(){
        try{
            var spokenText = await SpeechAndroid.startSpeech();
            ToastAndroid.show(spokenText , ToastAndroid.LONG);
        } catch (error) {
            console.error(error);
        }
    }
    render() {
        return (
            <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit index.android.js
        </Text>
        <Text style={styles.instructions}>
          Shake or press menu button for dev menu
        </Text>
        <TouchableHighlight onPress={this._onPressButton}>
          <Text style={styles.instructions}>Teste</Text>
        </TouchableHighlight>
      </View>
    );
  }
}
Clone this wiki locally