Coder Social home page Coder Social logo

patgbull / aframe-speech-command-component Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lmalave/aframe-speech-command-component

0.0 2.0 0.0 2.6 MB

A speech recognition component for the A-Frame WebVR library

Home Page: https://lmalave.github.io/aframe-speech-command-component/

License: MIT License

JavaScript 100.00%

aframe-speech-command-component's Introduction

aframe-speech-command-component

A speech command component for A-Frame.

The aframe-speech-command-component components provide speech commands that you can easily integrate into an aframe scene.

The speech command can set an attribute of a target element, or can also execute a function on a target Component.

The dist/aframe-speech-command-component.js file defines 2 components:

  • A speech-command component that can be added to any entity to define an action to take based on a speech command
  • An annyang-speech-recognition component that provides the speech recognition implementation based on the annyang Speech Recognition library: https://github.com/TalAter/annyang

Although this implementation uses annyang for speech recognition, any speech recognition javascript library can be integrated using the same pattern as annyang-speech-recognition

API

Property Description Default Value
command the text of the speech command
type "attribute" to change an attribute or "function" to execute a function
targetElement the component to execute the function on.
targetComponent the element that contains the attribute to change or contains the component to execute the function on. This is optional since by default the target will be entity that the component belongs to.
function the name of the function. For now the function must take no parameters.
attribute the attribute to change
value "the value to change the attribute to
keyCode n optional numeric ASCII code to use as a shortcut (useful for development when quiet is a necessity)

Example: setting an attribute on target element

<a-entity speech-command="command: city; type: attribute; targetElement: #image-360; attribute: src; value: #city;"></a-entity>

Example: executing a function on target Component

<a-entity speech-command="command: go; type: function; targetElement: #cursor; targetComponent: teleporter; function: teleport; keyCode: 13"></a-entity>

Installation

Browser

Install and use by directly including the browser files:

To integrate aframe-speech-command-component to an aframe scene, the following must be added:

  • The annyang speech recognition script and the aframe-speech-command-component.js script (found in the dist folder)
    <script src="//cdnjs.cloudflare.com/ajax/libs/annyang/2.5.0/annyang.min.js"></script>
    <script src="aframe-speech-command-component.js"></script>
  • An entity with the annyang-speech-recognition component
    <a-entity id="annyang" annyang-speech-recognition></a-entity>
  • One or more entities with the speech-command component
<a-entity id="menu"
              speech-command__show="command: show menu; type: attribute; attribute: visible; value: true;"
              speech-command__hide="command: hide menu; type: attribute; attribute: visible; value: false;">
              ...
              ...
</a-entity>

Note that multiple instances of the speech-command component are allowed on the same entity as shown above.

Browser Compatibility

This implementation is currently only compatible with the Google Chrome browser since it is based on that browser's Speech Recognition API.

The following are verified compatibility tests and results:

Browser OS Works?
Chrome 55 Mac OS 10.12 Yes
Chrome 55 Android 6.0.1 Yes
Chrome 55 iOS 10 No

Other versions of Chrome should also work, such as Chrome on Windows 10.

Firefox also has experimental support the Speech Recogntion API in versions Gecko 44+, so the aframe-speech-command-component may be compatible with those browsers as well. More information can be found here: https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API/Using_the_Web_Speech_API

npm

Install via npm:

npm install 

Then require and use.

require('aframe');
require('aframe-speech-command-component');

Public Demo

Demos are available publicly at:

https://lmalave.github.io/aframe-speech-command-component/examples/index.html

Image gallery demo

Say "show menu" to bring up menu

Say "go to cubes", "go to city", or "go to lake" to show any of the 3 images

Say "hide menu" to hide menu

This scene is based on the Image Gallery aframe.io demo: https://github.com/aframevr/360-image-gallery-boilerplate

Teleporter demo

Say "start move" to activate raycaster

Say "go to" to teleport to location of marker (with raycaster activated)

Say "cancel move" to deactivate raycaster

This scene is based on the Hello Metaverse aframe.io demo: https://aframe.io/examples/showcase/hello-metaverse/

Running demos locally

A node.js app is provided here with the Image Gallery and Teleport demos described above.

To run, first execute: npm install

Then execute: npm start

The application will then be running on http://localhost:8000 and your default browser should automatically open on this page

Troubleshooting

speech commands not working

If the speech commands are not working, first verify that the page has access to the microphone.

When you first load a page with speech commands in the browser, you should see the following prompt to grant access to the microphone:

If the page has already been granted access to the microphone, you should see a red dot on the tab and a camera icon in the URL bar, as shown below:

aframe-speech-command-component's People

Contributors

lmalave avatar

Watchers

 avatar  avatar

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.