Speech to text recognition with remote fallback (Native/External)
- 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
https://puemos.github.io/speechless
$ npm i speechless --save
$ yarn add speechless
<script src="https://rawgit.com/puemos/speechless/master/dist/speechless.umd.js"></script>
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()
function () {}
Emitted on successful recognition start
function () {}
Emitted after successful recognition end
function () {}
Emitted after a force stop.
function () {}
Emitted when the the audio is being sent to 3-rd party service
function (event) {}
Emitted when the new recognition data is avialible
event.detail === 'hello world'
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.
Shy Alter | GitHub/puemos | Twitter/@puemos |
---|
MIT