googlecreativelab / obvi

Licence: Apache-2.0 license
A Polymer 3+ webcomponent / button for doing speech recognition

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to obvi

Automatic speech recognition
End-to-end Automatic Speech Recognition for Madarian and English in Tensorflow
Stars: ✭ 2,751 (+4994.44%)
Mutual labels:  speech-recognition, automatic-speech-recognition
paper-chip
A chip web component made with Polymer 2 following Material Design guidelines
Stars: ✭ 30 (-44.44%)
Mutual labels:  polymer, polymer2
resizable-panels
Web Component that allows to resize its childrens vertically or horizontally
Stars: ✭ 18 (-66.67%)
Mutual labels:  polymer, polymer2
sova-asr
SOVA ASR (Automatic Speech Recognition)
Stars: ✭ 123 (+127.78%)
Mutual labels:  speech-recognition, automatic-speech-recognition
toggle-icon
toggle-icon is a custom element created with Polymer. It provides an extremely powerful and customizable switch that looks like a paper-icon-button.
Stars: ✭ 21 (-61.11%)
Mutual labels:  polymer, polymer2
demo vietasr
Vietnamese Speech Recognition
Stars: ✭ 22 (-59.26%)
Mutual labels:  speech-recognition, automatic-speech-recognition
page-title
A Polymer element for easily updating a webpage's title, such as in a SPA.
Stars: ✭ 13 (-75.93%)
Mutual labels:  polymer, polymer2
wenet
Production First and Production Ready End-to-End Speech Recognition Toolkit
Stars: ✭ 2,384 (+4314.81%)
Mutual labels:  speech-recognition, automatic-speech-recognition
vaadin-dialog
High quality web component for modal dialogs. Part of the Vaadin platform.
Stars: ✭ 15 (-72.22%)
Mutual labels:  polymer, polymer2
stl-part-viewer
A lit-element web component that uses Three.js to display an STL model file.
Stars: ✭ 19 (-64.81%)
Mutual labels:  polymer, webcomponent
soxan
Wav2Vec for speech recognition, classification, and audio classification
Stars: ✭ 113 (+109.26%)
Mutual labels:  speech-recognition, automatic-speech-recognition
vaadin-split-layout
The Web Component which allows you to partition a layout into resizeable areas. Part of the Vaadin components.
Stars: ✭ 40 (-25.93%)
Mutual labels:  polymer, polymer2
deep avsr
A PyTorch implementation of the Deep Audio-Visual Speech Recognition paper.
Stars: ✭ 104 (+92.59%)
Mutual labels:  speech-recognition, automatic-speech-recognition
Awesome Speech Recognition Speech Synthesis Papers
Automatic Speech Recognition (ASR), Speaker Verification, Speech Synthesis, Text-to-Speech (TTS), Language Modelling, Singing Voice Synthesis (SVS), Voice Conversion (VC)
Stars: ✭ 2,085 (+3761.11%)
Mutual labels:  speech-recognition, automatic-speech-recognition
kaldi-long-audio-alignment
Long audio alignment using Kaldi
Stars: ✭ 21 (-61.11%)
Mutual labels:  speech-recognition, automatic-speech-recognition
identicon-avatar
👾 GitHub style identicon avatar
Stars: ✭ 15 (-72.22%)
Mutual labels:  polymer, polymer2
hf-experiments
Experiments with Hugging Face 🔬 🤗
Stars: ✭ 37 (-31.48%)
Mutual labels:  speech-recognition, automatic-speech-recognition
2018-dlsl
UPC Deep Learning for Speech and Language 2018
Stars: ✭ 18 (-66.67%)
Mutual labels:  speech-recognition, automatic-speech-recognition
mapbox-gl
Polymer 2.0 custom element for mapbox-gl-js. Uses WebGL to render interactive maps from vector tiles and Mapbox styles - compatible with deck-gl.
Stars: ✭ 24 (-55.56%)
Mutual labels:  polymer, polymer2
vaadin-context-menu
The responsive Web Component for showing context dependent items for any element on the page. Part of the Vaadin components.
Stars: ✭ 26 (-51.85%)
Mutual labels:  polymer, polymer2

Published on webcomponents.org License

OBVI

One Button for Voice Input is a customizable webcomponent built with Polymer 3+ to make it easy for including speech recognition in your web-based projects. It uses the Speech Recognition API, and for unsupported browsers it will fallback to a client-side Google Cloud Speech API solution.

example

Run example

With npm installed, in the root of this repo:

npm install
npm start

Setting up your project

As of Polymer 3, all dependencies are managed through NPM and module script tags. You can simply add obvi to your project using:

npm install --save obvi-component

And then the following:

<!DOCTYPE html>
<html>
  <head>
	<script src="node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
  </head>
  <body>
  
    <voice-button id="voice-button" cloud-speech-api-key="YOUR_API_KEY" autodetect></voice-button>

    <script type="module">
    
      import './node_modules/obvi/voice-button.js';

      var voiceEl = document.querySelector('voice-button'),
        transcriptionEl = document.getElementById('transcription');

      // can check the supported flag, and do something if it's disabled / not supported
      console.log('does this browser support WebRTC?', voiceEl.supported);

      voiceEl.addEventListener('mousedown', function(event){
        transcriptionEl.innerHTML = '';
      })

      var transcription = '';
      voiceEl.addEventListener('onSpeech', function(event){
        transcription = event.detail.speechResult;
        transcriptionEl.innerHTML = transcription;
        console.log('Speech response: ', event.detail.speechResult)
        transcriptionEl.classList.add('interim');
        if(event.detail.isFinal){
          transcriptionEl.classList.remove('interim');
        }
      })

      voiceEl.addEventListener('onStateChange', function(event){
        console.log('state:',event.detail.newValue);
      })

    </script>
  </body>
</html>

Note: You must run your app from a web server for the HTML Imports polyfill to work properly. This requirement goes away when the API is available natively.

Also Note: If your app is running from SSL (https://), the microphone access permission will be persistent. That is, users won't have to grant/deny access every time.

For a single-build with one bundled file:

Static hosting services like GitHub Pages and Firebase Hosting don't support serving different files to different user agents. If you're hosting your application on one of these services, you'll need to serve a single build like so:

<script type="module" src="node_modules/obvi/voice-button.js"></script>

or

import './node_modules/obvi/dist/voice-button.js'

You can also customize the polymer build command in package.json and create your own build file to futher suit your needs.

Usage

Basic usage is:

<voice-button cloud-speech-api-key="YOUR_API_KEY"></voice-button>

Options

Name Description Type Default Options / Examples
cloudSpeechApiKey Cloud Speech API is the fallback when the Web Speech API isn't available. Provide this key to cover more browsers. String null <voice-button cloud-speech-api-key="XXX"></voice-button>
flat Whether or not to include the shadow. Boolean false <voice-button flat>
autodetect By default, the user needs to press & hold to capture speech. If this is set to true, it will auto-detect silence to finish capturing speech. Boolean false <voice-button autodetect>
language Language for SpeechRecognition interface. If not set, will default to user agent's language setting. See here for more info. String 'en-US' <voice-button language="en-US">
disabled Disables the button for being pressed and capturing speech. Boolean false <voice-button disabled>
keyboardTrigger How the keyboard will trigger the button String 'space-bar' <voice-button keyboard-trigger="space-bar"> space-bar, all-keys, none
clickForPermission If set to true, will only ask for browser microphone permissions when the button is clicked (instead of immediately) Boolean false <voice-button click-for-permission="true"
hidePermissionText If set to true, the warning text for browser access to the microphone will not appear Boolean false hide-permission-text="true"

CSS Variables

You can customize the look of the button using these CSS variables (default values shown):

voice-button{
	--button-diameter: 100px;
	--mic-color: #FFFFFF;
	--text-color: #666666;
	--button-color: #666666;
	--circle-viz-color: #000000;
}

Events

You can listen for the following custom events from the voice button:

Name Description Return
onSpeech Result from the speech handler detail: { result: { speechResult : String, confidence : Number, isFinal : Boolean, sourceEvent: Object }
onSpeechError The raw event returned from the SpeechRecognition onerror handler See here
onStateChange When the button changes state detail: { newValue: String, oldValue: String} see below for listening states

Listening states:

  IDLE: 'idle',
  LISTENING: 'listening',
  USER_INPUT: 'user-input',
  DISABLED: 'disabled'

Microphone Permissions

When the component is loaded, microphone access is checked (unless click-for-permission="true" is set, then it will ask one the button is clicked). If the host's mic access is blocked, there will be a warning shown. The language of the text matches the language attribute for the component (defaults to "en-US"). If the color of the text needs to be customized, you can use the --text-color CSS variable.

Microphone not allowed

Browser Compatibility

This component defaults to using the Web Speech API. If the browser does not support that, it will fall back to WebRTC in order to capture audio on the client and post it to the Google Cloud Speech API. Make sure to create an API Key and have the cloud-speech-api-key attribute (see above in Options) filled out in order to use this fallback. You can check the supported property of the button once it's loaded in to see if it has browser support.

When the fallback is used, there will be no streaming speech recognition; the speech comes back all at once.

Browser Support Features
Firefox Stable / Aurora / Nightly Cloud Speech fallback
Google Chrome Stable / Canary / Beta / Dev Web Speech API
Opera Stable / NEXT Cloud Speech fallback
Android Chrome / Firefox / Opera Cloud Speech fallback
Microsoft Edge Normal Build Cloud Speech fallback
Safari 11 Stable Cloud Speech fallback

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Credits

This component was authored by @nick-jonas, and was built atop some great tools - special thanks to the Polymer team (esp. Chris Joel), Jonathan Schaeffer for testing help, @jasonfarrell for fallback help, @GersonRosales & @danielstorey for showing a working recording example in iOS11 early days.

This is an experiment, not an official Google product. We’ll do our best to support and maintain this experiment but your mileage may vary.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].