Skip to content
JoaoCnh edited this page Jan 21, 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.2.0 - Coming soon

  • Error Handling
  • Custom Prompt
  • Several Locales to choose from (I've implemented some already, still need to finish up)

##Example of what's to come

...
var spokenText = await SpeechAndroid.startSpeech("Speak yo", SpeechAndroid.GERMAN);
...

This will automatically start recognizing and adjusting for the German Language. On release I'll update these docs with every single Locale available.

#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 VoiceTest 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}>Speak</Text>
                </TouchableHighlight>
            </View>
        );
     }
}
Clone this wiki locally