Skip to content

Commit

Permalink
[src] Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
wenkesj committed May 6, 2016
0 parents commit 4b2667d
Show file tree
Hide file tree
Showing 10 changed files with 631 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*.{js,less}]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar

build/
VoiceModule.iml
45 changes: 45 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"undef": "true",
"browser": false,
"esnext": true,
"globals": {
"console": true,
"__filename": true,
"__dirname": true,
"require": true,
"module": true,
"exports": true,
"setInterval": true,
"clearInterval": true,
"fetch": true,
"await": true
},
"strict": false,
"expr": true,
"globalstrict": true,
"quotmark": "single",
"smarttabs": true,
"trailing": true,
"curly": true,
"debug": false,
"devel": false,
"eqeqeq": true,
"eqnull": true,
"evil": true,
"forin": false,
"immed": true,
"laxbreak": false,
"newcap": true,
"noarg": true,
"noempty": false,
"nonew": true,
"nomen": false,
"onevar": false,
"plusplus": false,
"undef": true,
"sub": false,
"white": false,
"eqeqeq": false,
"latedef": "nofunc",
"sub": true
}
81 changes: 81 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# React Native Voice
A speech-to-text library for [React Native](https://facebook.github.io/react-native/).

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

# Install

```sh
npm i react-native-voice --save
```

## Android
- In `android/setting.gradle`

```gradle
...
include ':VoiceModule', ':app'
project(':VoiceModule').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-voice/android')
```

- In `android/app/build.gradle`

```gradle
...
dependencies {
...
compile project(':VoiceModule')
}
```

- In `MainActivity.java`

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

# Usage

```javascript
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() | Starts listening for speech. 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. | `{ value: [..., 'Speech recognized'] }` | 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
48 changes: 48 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.facebook.react:react-native:0.17.+'
}
8 changes: 8 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wenkesj.voice"
xmlns:tools="http://schemas.android.com/tools">

<uses-sdk tools:overrideLibrary="com.facebook.react" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Loading

0 comments on commit 4b2667d

Please sign in to comment.