speech-to-text
Advanced tools
Comparing version 0.3.7 to 0.3.8
@@ -19,6 +19,7 @@ 'use strict'; | ||
(slow, much more accuate) | ||
onFinishedListening - a callback that will be called when the speech recognition stops listening | ||
language - the language to interpret against. Default is US English. | ||
*/ | ||
function SpeechToText(onAnythingSaid, onFinalised) { | ||
var language = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'en-US'; | ||
function SpeechToText(onAnythingSaid, onFinalised, onFinishedListening) { | ||
var language = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'en-US'; | ||
@@ -40,6 +41,8 @@ _classCallCheck(this, SpeechToText); | ||
var finalTranscript = ''; | ||
// process both interim and finalised results | ||
this.recognition.onresult = function (event) { | ||
var interimTranscript = ''; | ||
var finalTranscript = ''; | ||
// concatenate all the transcribed pieces together (SpeechRecognitionResult) | ||
@@ -59,2 +62,6 @@ for (var i = event.resultIndex; i < event.results.length; i += 1) { | ||
}; | ||
this.recognition.onend = function () { | ||
return onFinishedListening(); | ||
}; | ||
} | ||
@@ -61,0 +68,0 @@ |
{ | ||
"name": "speech-to-text", | ||
"version": "0.3.7", | ||
"version": "0.3.8", | ||
"description": "A speech to text module.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -35,2 +35,3 @@ # Speech To Text | ||
- onFinalised: this is a callback function that is called with the full text as it has been resolved in the cloud. | ||
- onFinishedListening: this is a callback function that is called when the speech recognitions stops listening. | ||
- language: This is an optional string that specifies the language to be interpreted as. Default is United States English. 'en-US' | ||
@@ -48,3 +49,3 @@ | ||
Initiates listening to speech input and will continue to call the callback functions provided until the speech is finalised. After which you'll need to call this function again. | ||
Initiates listening to speech input and will continue to call the callback functions provided until the speech recognition stops listening. After which you'll need to call this function again. | ||
@@ -51,0 +52,0 @@ ## License |
7080
77
53