Home

Awesome

choo-stt stability

npm version build status downloads js-standard-style

Simple speech-to-text in the browser for choo

Usage

var choo = require('choo')
var html = require('choo/html')

var app = choo()
app.use(require('choo-stt')())
app.route('/', mainView)
app.mount('body')

function mainView (state, emit) {
  return html`
    <body>
      <button onclick=${onclick}>Listen</button>
    </body>
  `

  function onclick () {
    emit('stt:start')
  }
}
function listen (state, emitter) {
  emitter.on('stt:result', function (result) {
    console.log(result)
  })
}

Events

stt:error | stt.events.ERROR

Fired whenever there is an error related to speech recognition.

stt:audio-start | stt.events.AUDIO_START

Fired when the user agent has started to capture audio.

stt:audio-end | stt.events.AUDIO_END

Fired when the user agent has finished capturing audio.

stt:start | stt.events.START

Fired when the speech recognition service has begun listening to incoming audio.

stt:end | stt.events.END

Fired when the speech recognition service has disconnected.

stt:stop | stt.events.STOP

Emit this event to stops the speech recognition service from listening to incoming audio, and attempts to return a SpeechRecognitionResult using the audio captured so far.

stt:abort | stt.events.ABORT

Stops the speech recognition service from listening to incoming audio.

stt:no-match | stt.events.NO_MATCH

Fired when the speech recognition service returns a final result with no significant recognition. This may involve some degree of recognition, which doesn't meet or exceed the confidence threshold.

stt:result | stt.events.RESULT

Fired when the speech recognition service returns a result — a word or phrase has been positively recognized and this has been communicated back to the app.

stt:sound-start | stt.events.SOUND_START

Fired when any sound — recognisable speech or not — has been detected.

stt:sound-end | stt.events.SOUND_END

Fired when any sound — recognisable speech or not — has stopped being detected.

stt:speech-start | stt.events.SPEECH_START

Fired when sound that is recognised by the speech recognition service as speech has been detected.

stt:speech-end | stt.events.SPEECH_END

Fired when speech recognised by the speech recognition service has stopped being detected.

stt:set-command | stt.events.SET_COMMAND

Set a command. When this event is fired, it set a command so it executes a callback when the command pattern is listened.

API

stt = require('choo-stt')

License

MIT