GithubHelp home page GithubHelp logo

choo-stt's Introduction

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')

  • state.stt.lang: Returns or set the language of the current recognition. Defaults to Html lang element, or user agent lang if tag is not set.
  • state.stt.continuos: Controls whether continuous results are returned for each recognition, or only a single result. Defaults false.
  • state.stt.interimResults: Controls whether interim results should be returned true or not false. Interim results are results that are not yet final. Defaults false.
  • state.stt.maxAlternatives: Sets the maximum number of SpeechRecognitionAlternatives provided per result. Defaults to 1.
  • state.stt.serviceURI: Specifies the location of the speech recognition service used by the current SpeechRecognition to handle the actual recognition. The default is the user agent's default speech service.

License

MIT

choo-stt's People

Contributors

yerkopalma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

the-cc-dev

choo-stt's Issues

Extend API

Right now this module only wrap what is actually offered (and a bit less) by SpeechRecognition API. Now what seems like a natural addition is the capability to define commands like annyang does. Now I'm not sure if we should keep it minimalistic or got for the commands API.

If we go to, it should be like this

// <command name with named parameters>, callback the listened parameters
emit('stt:set-command', 'command :name', callback(name))

The callback will run when a listened speech fits in the command definition

use a constructor?

Just noticed the constructor API is different from choo-tts. I think it'd be nice if they were similar, e.g.

app.use(require('choo-stt'))   // old
app.use(require('choo-stt')()) // new

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.