speech-to-text
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -1,3 +0,13 @@ | ||
export default class SpeechToText { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var SpeechToText = function () { | ||
/* | ||
@@ -11,3 +21,7 @@ Arguments for the constructor. | ||
*/ | ||
constructor(onAnythingSaid, onFinalised, language = 'en-US') { | ||
function SpeechToText(onAnythingSaid, onFinalised) { | ||
var language = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'en-US'; | ||
_classCallCheck(this, SpeechToText); | ||
// Check to see if this browser supports speech recognition | ||
@@ -18,3 +32,3 @@ if (!('webkitSpeechRecognition' in window)) { | ||
const WebkitSpeechRecognition = window.webkitSpeechRecognition; | ||
var WebkitSpeechRecognition = window.webkitSpeechRecognition; | ||
this.recognition = new WebkitSpeechRecognition(); | ||
@@ -28,8 +42,8 @@ | ||
// process both interim and finalised results | ||
this.recognition.onresult = event => { | ||
let interimTranscript = ''; | ||
let finalTranscript = ''; | ||
this.recognition.onresult = function (event) { | ||
var interimTranscript = ''; | ||
var finalTranscript = ''; | ||
// concatenate all the transcribed pieces together (SpeechRecognitionResult) | ||
for (let i = event.resultIndex; i < event.results.length; i += 1) { | ||
const transcriptionPiece = event.results[i][0].transcript; | ||
for (var i = event.resultIndex; i < event.results.length; i += 1) { | ||
var transcriptionPiece = event.results[i][0].transcript; | ||
// check for a finalised transciption in the cloud | ||
@@ -52,6 +66,14 @@ if (event.results[i].isFinal) { | ||
*/ | ||
startListening() { | ||
this.recognition.start(); | ||
} | ||
} | ||
_createClass(SpeechToText, [{ | ||
key: 'startListening', | ||
value: function startListening() { | ||
this.recognition.start(); | ||
} | ||
}]); | ||
return SpeechToText; | ||
}(); | ||
exports.default = SpeechToText; |
{ | ||
"name": "speech-to-text", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "A speech to text module.", | ||
@@ -8,3 +8,3 @@ "main": "./lib/index.js", | ||
"start": "node example/server.js", | ||
"build": "rm -rf lib && ./node_modules/.bin/babel src -d lib", | ||
"build": "rm -rf lib && ./node_modules/.bin/babel --presets es2015 -d lib/ src/", | ||
"prepublish": "npm run build" | ||
@@ -29,2 +29,3 @@ }, | ||
"babel-cli": "^6.16.0", | ||
"babel-preset-es2015": "^6.16.0", | ||
"eslint": "^3.7.0", | ||
@@ -31,0 +32,0 @@ "eslint-config-airbnb": "^12.0.0", |
# speech-recognition | ||
A [React](https://facebook.github.io/react/) speech recognition component for the Chrome Browser . | ||
Speech to text module. | ||
## Install | ||
$ npm install --save react-speech-recognition | ||
$ npm install --save speech-to-text | ||
## Usage | ||
``` | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import SpeechRecognition from 'react-speech-recognition'; | ||
ReactDOM.render(( | ||
<SpeechRecognition | ||
className="test" onChange={(value) => console.log(value)} onEnd={(value) => console.log(value)} /> | ||
), document.getElementById('app')); | ||
``` | ||
##Example | ||
*run demo* | ||
``` | ||
npm install | ||
npm start | ||
``` | ||
open [http://localhost:8080/](http://localhost:8080/) | ||
## props | ||
* `className`: the css class name of the wrapper. | ||
* `onChange`: run when you start speaking, the value is what you say. | ||
* `onEnd`: run when you stop speaking, the value is what you say. | ||
## License | ||
react-speech-recognition-input is released under the MIT license. | ||
speech-to-text is released under the MIT license. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5401
73
7
12