Coder Social home page Coder Social logo

johnbicknell / react-native-voice Goto Github PK

View Code? Open in Web Editor NEW

This project forked from react-native-voice/voice

0.0 1.0 0.0 56 KB

React Native Native Voice library for iOS and Android

Python 6.57% Java 38.68% JavaScript 34.24% Objective-C 20.51%

react-native-voice's Introduction

React Native Voice

A speech-to-text library for React Native.

NOTE, currently only supports Android. Contribute to make this a universal module!

Install

npm i react-native-voice --save

Android

  • In android/setting.gradle
...
include ':VoiceModule', ':app'
project(':VoiceModule').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-voice/android')
  • In android/app/build.gradle
...
dependencies {
    ...
    compile project(':VoiceModule')
}
  • In MainActivity.java
import com.facebook.react.ReactPackage;
...
import com.wenkesj.voice.VoicePackage; // <------ Add this!
...

public class MainActivity extends ReactActivity {
...
    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new VoicePackage() // <------ Add this!
        );
    }
}

Example

Full example located in /VoiceTest.

Usage

import Voice from 'react-native-voice';

Methods

Accessible methods to perform actions.

Method Name Description Platform
isAvailable(callback) Checks whether a speech recognition service is available on the system. Android
start(locale) Starts listening for speech for a specific locale. Returns null if no error occurs. Android
stop() Stops listening for speech. Returns null if no error occurs. Android
cancel() Cancels the speech recognition. Returns null if no error occurs. Android
destroy() Destroys the current SpeechRecognizer instance. Returns null if no error occurs. Android
isRecognizing() Return if the SpeechRecognizer is recognizing. Android

Events

Methods that are invoked when a native event emitted.

Event Name Description Event Platform
onSpeechStart(event) Invoked when .start() is called without error. { error: false } Android
onSpeechRecognized(event) Invoked when speech is recognized. { error: false } Android
onSpeechEnd(event) Invoked when SpeechRecognizer stops recognition. { error: false } Android
onSpeechError(event) Invoked when an error occurs. { error: Description of error as string } Android
onSpeechResults(event) Invoked when SpeechRecognizer is finished recognizing. { value: [..., 'Speech recognized'] } Android
onSpeechPartialResults(event) Invoked when any results are computed. { value: [..., 'Partial speech recognized'] } Android
onSpeechVolumeChanged(event) Invoked when pitch that is recognized changed. { value: pitch in dB } Android

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.