Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

speech-to-text

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

speech-to-text - npm Package Compare versions

Comparing version 0.4.4 to 0.4.7

23

lib/index.js

@@ -28,8 +28,8 @@ 'use strict';

// Check to see if this browser supports speech recognition
if (!('webkitSpeechRecognition' in window)) {
throw new Error("This browser doesn't support speech recognition. Try Google Chrome.");
if (!('webkitSpeechRecognition' in window) && !('SpeechRecognition' in window)) {
throw new Error("This browser doesn't support speech recognition. Try Google Chrome or Firefox.");
}
var WebkitSpeechRecognition = window.webkitSpeechRecognition;
this.recognition = new WebkitSpeechRecognition();
var SpeechRecognition = window.webkitSpeechRecognition || window.SpeechRecognition;
this.recognition = new SpeechRecognition();

@@ -67,9 +67,14 @@ // Keep listening even if the speaker pauses, and return interim results.

/*
Explicitly start listening.
Listening will need to be started again after a finalised result is returned.
*/
_createClass(SpeechToText, [{
key: 'stopListening',
value: function stopListening() {
this.recognition.stop();
}
/*
Explicitly start listening.
Listening will need to be started again after a finalised result is returned.
*/
_createClass(SpeechToText, [{
}, {
key: 'startListening',

@@ -76,0 +81,0 @@ value: function startListening() {

{
"name": "speech-to-text",
"version": "0.4.4",
"version": "0.4.7",
"description": "A speech to text module.",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -5,11 +5,12 @@ # Speech To Text

It's designed to listen continuously to a user (i.e. pauses are ok), and then converting that speech to text.
It's designed to listen continuously to a user (i.e. pauses are ok), and then
converts that speech to text.
## Install
`npm install --save speech-to-text`
`npm install speech-to-text`
## Usage
````
```
import SpeechToText from 'speech-to-text';

@@ -19,5 +20,6 @@

const onFinalised = text => console.log(`Finalised text: ${text}`);
const onFinishedListening = () => console.log('Done listening.');
try {
const listener = new SpeechToText(onAnythingSaid, onFinalised);
const listener = new SpeechToText(onAnythingSaid, onFinalised, onFinishedListening);
listener.startListening();

@@ -27,3 +29,3 @@ } catch (error) {

}
````
```

@@ -36,21 +38,35 @@ Demo [here](http://apps.golightlyplus.com/speech-to-text-demo/).

- onAnythingSaid: this is a callback function that is called with text as it's being said
- 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'
- onAnythingSaid: this is a callback function that is called with text as it's
being said.
- 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'
The constructor will throw an error if speech recognition is not supported by the browser.
````
// Check to see if this browser supports speech recognition
if (!('webkitSpeechRecognition' in window)) {
throw new Error("This browser doesn't support speech recognition. Try Google Chrome.");
The constructor will throw an error if speech recognition is not supported by
the browser.
```
if (
!('webkitSpeechRecognition' in window) &&
!('SpeechRecognition' in window)
) {
throw new Error("This browser doesn't support speech recognition. Try Google Chrome or Firefox.");
}
````
```
### startListening
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.
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.
### stopListening
Does just that. Stops listening.
## License
MIT
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc