Skip to content

Instantly share code, notes, and snippets.

@bcardarella
Created February 14, 2017 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcardarella/a68e0e874afd6f9bef7bec92b231e2e0 to your computer and use it in GitHub Desktop.
Save bcardarella/a68e0e874afd6f9bef7bec92b231e2e0 to your computer and use it in GitHub Desktop.
speech
import Ember from 'ember';
const {
get,
set
} = Ember;
export default Ember.Component.extend({
tagName: 'button',
init() {
this._super(...arguments);
let recognition = new webkitSpeechRecognition();
recognition.lang = 'en-US';
recognition.onstart = () => {
set(this, 'isActive', true);
console.log('started');
};
set(this, 'recognition', recognition);
recognition.onresult = (event) {
console.log(event.results[0][0].transcript);
};
},
click(event) {
let recognition = get(this, 'recognition');
recognition.start();
},
isActive: false
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
button {
height: 20px;
width: 40px;
}
button img {
width: 20px;
height: 20px;
}
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{speech-button}}
<br>
<br>
<img src="http://www.freeiconspng.com/uploads/microphone-icon--icon-search-engine-9.png">
{
"version": "0.11.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.10.2",
"ember-data": "2.11.0",
"ember-template-compiler": "2.10.2",
"ember-testing": "2.10.2"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment