GithubHelp home page GithubHelp logo

ngx-speech's Introduction

NgxSpeech

Voice recognition for Angular 5

Build Status

Principle

NgxSpeech allows to trigger actions using voice commands.

The ngSpeechContext directive allows to define context. For instance, "menu" could be a context that will allow to activate the menu commands, and "search" another context enabling search commands.

Example:

<div [ngSpeechContext]="['pizza']">
  Say "pizza" and then choose your pizza
</div>

The ngSpeechAction directive allow to register a command into a context and bind it to method.

Example:

<li [ngSpeechActionContext]="['pizza']"
    [ngSpeechActionCommand]="'Napolitana'"
    [ngSpeechAction]="order">Napolitana</li>

will trigger the order() method if we say "Napolitana" only if we are in the "pizza" context (i.e. we said "pizza" before saying "Napolitana").

All the words corresponding to a command or a context are referenced in a grammar.

A command or a sub-context can be activcayed only if we are in the parent context, but a first-level context can activatyed from anywhere.

The SpeechService exposes useful observables:

  • message, the last recognized word(s), even if it is not part of the current grammar,
  • context, the current context as a path (like "menu/account"),
  • command, the last comnmand.

Installation

npm install ngx-speech

Usage

In our app module, we need to import the SpeechModule and to provide the language to use:

@NgModule({
    ...
    imports: [
        ...
        SpeechModule,
    ],
    providers: [
        ...
        { provide: 'SPEECH_LANG', useValue: 'en-US' },
    ],
    ...
})
export class AppModule { }

To start the speech recognition, we ned to call the start() method:

import { SpeechService } from 'ngx-speech';

...

    constructor(public speech: SpeechService) { }

    ngOnInit() {
        this.speech.start();
    }

ngx-speech's People

Contributors

ebrehault avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ngx-speech's Issues

Publish new versions to npm

Hello @ebrehault, could you publish version 0.0.5+ to npm? I'd like to get rid of rxjs-compat dependencies but I can't because I use version 0.0.4 which is the last published version and it uses an old version of rxjs...

Not recognizing the voice

Hi,
I tried installing this app and on clicking "Start Voice Recognition" it doesn't captures the voice.
Later the text automatically changes from "Stop Voice Recognition" to "Start Voice Recognition".
ngx-speech-error

SpeechRecognitionError after migration from Angular4 to 5

Hello,
We encounter this error in browser console on load of our application. Same code was working fine with Angular 4.

After migrating to Angular 5 , we see :
SpeechRecognitionError {isTrusted: true, error: "not-allowed", message: "", type: "error", target: SpeechRecognition, …}

Angular & components version : 5.2.5
ngx-speech version : 0.0.4

Any thoughts?

Import guidance required

I am using angular 9 and you mentioned to put -
imports: [ ... SpeechModule, ],

which is fine but it's giving error and reason I think I need to define import at top of file,
I tried
import { SpeechModule } from 'ngx-speech';
getting error

Please specify this import from where this SpeechModule needs to be imported in app.module.ts after installing ngx-speech

I wanna use this to https://www.rajeshkumaryadav.com/#/auth when user will authenticated, it will say you can choose any of pages just say the name, for example you can say 'About' once user will listen this from my existing code, role of your ngx-speech will start, your ngx-speech will take input as 'About' and then I will code for it to set the route for about.

Please answer about import on priority basis.

Adjust continous recognition and time before automatically ending

Hello!
From where it is possible to adjust the time spare before the recognition will automatically stop? At the stop, if I make a break of a few milliseconds, the recognition will end. How can set it to a different value or set the recognition not to be continuous?
Can you provide some documentation on this topic?
Thank you!

Using the service crashes app when browser is not supported

Should probably surround with an if(window.SpeechRecognition)

Error Stack (Safari)
[Error] ERROR
TypeError: undefined is not a constructor (evaluating 'new SpeechRecognition()')
SpeechService
_createClass
_createProviderInstance$1
resolveNgModuleDep
createClass
createDirectiveInstance
createViewNodes
callViewAction
execComponentViewsAction
createViewNodes
createEmbeddedView
callWithDebugContext
createEmbeddedView
createEmbeddedView
_updateView
set
updateProp
checkAndUpdateDirectiveInline
debugCheckAndUpdateNode
debugCheckDirectivesFn
(anonymous function)
checkAndUpdateView
callViewAction
execComponentViewsAction
checkAndUpdateView
callWithDebugContext
detectChanges
forEach
tick
_loadComponent
bootstrap
forEach
_moduleDoBootstrap
(anonymous function)
onInvoke
run
(anonymous function)
onInvokeTask
runTask
drainMicroTaskQueue
promiseReactionJob
error
View_ResultsPageComponent_0 (ResultsPageComponent.ngfactory.js:45)
logError (0:13611)
(anonymous function)
handleError (0:1284)
handleError (1271:61)
run (870:138)
tick (0:5023)
_loadComponent (0:4991)
bootstrap (0:4979)
forEach
_moduleDoBootstrap (0:4750)
(anonymous function) (0:4712)
onInvoke (0:4094)
run (870:138)
(anonymous function) (870:858)
onInvokeTask (0:4085)
runTask (870:188)
drainMicroTaskQueue (870:595)
promiseReactionJob

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.