speechless v0.2.5
Speechless is a library to make working with Web Speech API on the web easier. It provides a consistent API for speech to text in different browsers, in the situation that the API is not available yet you can supply a fallback to your own speech to text API.
Why
- Save money and use native speech-to-text recognition
- Hide the complexity with a simple interface
- Easy events
- 100% test and coverage
- Types for better development
Demo
TypeDocs
https://puemos.github.io/speechless
Install
$ npm i speechless --save
$ yarn add speechless
<script src="https://rawgit.com/puemos/speechless/master/dist/speechless.umd.js"></script>
Usage
import { RecognitionFactory } from 'speechless';
// Create event listeners
const onData = (data: string | any) => console.log(data)
const onStart = () => console.log('start')
const onFetching = () => console.log('feching')
const onEnd = () => console.log('ended')
const onStop = () => console.log('stopped')
// Fallback function for remote call recognition
function remoteCall(blob: Blob){
return fetch("/remote/recognition", {
method: "POST",
body: blob
})
.then(function(res){ return res.json(); })
}
// Create new instance
const recognition = RecognitionFactory('en', remoteCall)
// Connect the listeners
recognition.addEventListener('end', onEnd)
recognition.addEventListener('data', onData)
recognition.addEventListener('fetching', onFetching)
recognition.addEventListener('stop', onStop)
recognition.addEventListener('start', onStart)
// Start listening
recognition.listen()
Events
Event 'start'
function () {}
Emitted on successful recognition start
Event 'end'
function () {}
Emitted after successful recognition end
Event 'stop'
function () {}
Emitted after a force stop.
Event 'fetching'
function () {}
Emitted when the the audio is being sent to 3-rd party service
Event 'data'
function (event) {}
Emitted when the new recognition data is avialible
event.detail === 'hello world'
Contributing
Speechless is an OPEN Open Source Project. This means that:
Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit.
Contributors
License
MIT